﻿Imports System.IO
Imports System.Xml
Public Class MapEditor
#Region "Dimensions and Variable Declarations"
    Inherits System.Windows.Forms.Form
    Implements IMessageFilter
	'sErr (Error message) and bAns (Save value reflection) are used in the SaveTextToFile and GetFileContents functions
    Private sErr As String, bAns As Boolean
	'First open is used to distinguish values when the form is first opened, to prevent them from occuring again (once over)
    Private FirstOpen = True
    Private ClearMapFailed = False
    'Total maps will be replaced when AtlasNodes is fully replaced
    Private TotalMaps As Integer
    'CurreMap is the current map number so it can be allocated in the AtlasNodes, This will be replaced when AtlasNodes is replaced
    Private CurreMap As Integer
    'Keycodes for Keydown and Keyup - Not currently used, and may be deleted (R7)
    Private WM_KEYDOWN As Integer = &H100
    Private WM_KEYUP As Integer = &H101
    'The following dimensions are specific per sector
    Private Map(15, 15) As Integer
    Public MapSafe(15, 15) As String
    'The following booleans portray whether or not a particular sector has a particular exit room exa: 1,1 has a south exit so MapS(0,0)=true
    Public MapE(15, 15), MapW(15, 15), MapN(15, 15), MapS(15, 15), MapU(15, 15), MapD(15, 15) As Boolean
    'The following dictates whether
    Public MapEOffMap(15, 15), MapWOffMap(15, 15), MapNOffMap(15, 15), MapSOffMap(15, 15) As Boolean
    Public MapEast(15, 15), MapWest(15, 15), MapNorth(15, 15), MapSouth(15, 15), MapUp(15, 15), MapDown(15, 15) As String
    Public MapEastLong(15, 15), MapWestLong(15, 15), MapNorthLong(15, 15), MapSouthLong(15, 15), MapUpLong(15, 15), MapDownLong(15, 15) As String
    Private MapDesc(15, 15) As String
    Private MapDescription(15, 15) As String
    Private MapNumber(15, 15) As Integer
    Private MapAcessible(15, 15) As Single
    Private MapEnvironment(15, 15) As Single
    Private MapDescriptionSet(15, 15) As Boolean
    Private MapNameSet(15, 15) As Boolean
    Private MapEnvironmentSet(15, 15) As Boolean
    Public MapProps(15, 15) As String
    Public MapMobiles(15, 15) As String
    'CurX and CurY is the currently selected sector location
    Public CurX As Integer, CurY As Integer
    'PlayerX and PlayerY are not currently used and may be deleted (R7)
    Public PlayerX As Integer = 0
    Public PlayerY As Integer = 0
    'Pad is used to draw the sectors onto, Canvas owns the pad and passes parenting to the main form
    Public pad As New Bitmap(750, 750)
    Public canvas As Graphics = Graphics.FromImage(pad)
    Public hastrace As Boolean = False
    Public hasrooms As Boolean = False
    Private PreventRedraw As Boolean = False
    'Erroneous variables that must be removed
    Public x As Integer, a As Integer
    Public y As Integer, b As Integer
    'MouseColumn and MouseRow are used to distinguish the current Mouse position, these can be merged into the subroutine and removed from header space.
    Private MouseColumn As Short, MouseRow As Short
#End Region
#Region "Functions"
    Public Function SetEnvironmentColor(ByVal x As Short, ByVal y As Short, ByVal color As String) As String
        'declare xml dimensions
        Dim m_xmld As XmlDocument
        Dim m_nodelist As XmlNodeList
        Dim m_node As XmlNode
        Dim CurNumber As String, CurName As String
        Try
            m_xmld = New XmlDocument()
            m_xmld.Load(Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", "Environments.xml"))
            m_nodelist = m_xmld.SelectNodes("/environmentlist/environment")
            For Each m_node In m_nodelist
                CurName = m_node.Attributes.GetNamedItem("name").Value
                CurNumber = m_node.Attributes.GetNamedItem("number").Value
                If Val(CurNumber) = Val(color) Or CurName = color Then 'color requested was found
                    Return m_node.Attributes.GetNamedItem("color").Value
                    Exit For
                End If
            Next
            'x and y is only sent for this error message, and is not used otherwise.
            SND("/RERROR: ENVIRON COLOR NOT FOUND : " + x.ToString + ":" + y.ToString + ":" + color)
            Return 0
        Catch errorVariable As Exception
            SND("/RERROR: " + errorVariable.ToString())
            Return 0
        End Try
    End Function
    Public Function SepByCapital(ByVal thestring As String) As String 'also truncates by word to 10 length
        Dim tmp As Integer
        Dim thechanged As String = ""
        If Len(thestring) > 0 Then
            For tmp = 1 To Len(thestring) Step 1
                If LCase(Mid(thestring, tmp, 1)) <> Mid(thestring, tmp, 1) And tmp > 1 Then 'letter is capitalized, and isn't the first letter
                    thechanged += " " + Mid(thestring, tmp, 1)
                Else
                    thechanged += Mid(thestring, tmp, 1)
                End If
            Next
            Return thechanged
        Else
            Return thestring
        End If
    End Function
    Public Function FileExists(ByVal FileFullPath As String) _
      As Boolean
        Dim f As New IO.FileInfo(FileFullPath)
        Return f.Exists
    End Function
    Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
        Dim keyCode As Keys = CType(CInt(m.WParam), Keys) And Keys.KeyCode
        If m.Msg = WM_KEYDOWN And keyCode = Keys.Escape Then
            Me.Close()
            Application.RemoveMessageFilter(Me) : Return True
        End If
        Return False
    End Function 'PreFilterMessage
    Public Function GetFileContents(ByVal FullPath As String, _
        Optional ByRef ErrInfo As String = "") As String

        Dim strContents As String
        Dim objReader As StreamReader
        Try
            objReader = New StreamReader(FullPath)
            strContents = objReader.ReadToEnd()
            Return strContents
            objReader.Close()
            objReader.Dispose()
        Catch Ex As Exception
            Return ""
            ErrInfo = Ex.Message
            MsgBox(ErrInfo, MsgBoxStyle.Critical, "ERROR!")
        End Try
    End Function
    Public Function AddZeros(ByVal thestring As String, ByVal acceptedlength As Integer) As String
        Dim strlen As Integer
        If Len(thestring) > acceptedlength Then
            Return thestring
        End If
        For strlen = Len(thestring) To acceptedlength - 1 Step 1
            thestring = "0" + thestring
        Next
        Return thestring
    End Function
    Public Function SaveTextToFile(ByVal strData As String, _
     ByVal FullPath As String, _
       Optional ByVal ErrInfo As String = "") As Boolean

        Dim bAns As Boolean = False
        Dim trynum As Short = 1
        Dim objReader As StreamWriter
        While bAns = False
            Try
                objReader = New StreamWriter(FullPath)
                objReader.Write(strData)
                objReader.Close()
                bAns = True
            Catch Ex As Exception
                ErrInfo = Ex.Message
                If trynum = 1000 Then
                    MsgBox(ErrInfo, MsgBoxStyle.Critical, "ERROR!")
                    bAns = True
                End If
            End Try
        End While
        Return bAns
    End Function
#End Region
    Private Sub LoadMapMaker(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FirstOpen = True
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                MapDesc(x, y) = "An Empty Room"
                MapDescription(x, y) = "You are here."
                MapAcessible(x, y) = 0
                MapEnvironment(x, y) = 100
                MapDescriptionSet(x, y) = False
                MapNameSet(x, y) = False
                MapEnvironmentSet(x, y) = False
            Next
        Next
        Dim theexitfont As New Font("Arial", 8)
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        curxandy.Text = LTrim(Str(CurX + 1)) + "," + LTrim(Str(CurY + 1))
        CurSectorName.Text = MapDesc(CurX, CurY)
        CurSectorDescription.Text = MapDescription(CurX, CurY)
        If MapAcessible(CurX, CurY) = 0 Then CheckBox3.Checked = False Else CheckBox3.Checked = True
        If MapSafe(CurX, CurY) = 0 Then CheckBox7.Checked = False Else CheckBox7.Checked = True
        xish = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10
        yish = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10
        xishPLUS = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10 + Val(TheRoomWidth)
        yishPLUS = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10 + Val(TheRoomHeight)
        Application.AddMessageFilter(Me)
        Button1_Click(0, System.EventArgs.Empty)
        LoadWorld()
        canvas.DrawString("o", theexitfont, Brushes.LightGreen, xish + 12, yish + 8)
    End Sub
    Public Sub SND(ByVal Txt As String)
        Txt = "/W " + Txt + "/W"
        Dim Switches As Integer = -1
        Dim TempStr As String
        Dim TempStr2 As String
        Dim TempInt As Integer
        Dim TempInt2 As Integer = 0
        For TempInt = 1 To Len(Txt) Step 1
            TempStr = Mid(Txt, TempInt, 1)
            If TempStr = "/" Then
                If Mid(Txt, TempInt, 2) = "/B" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&HFF)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/b" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&H66)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/C" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&HFFFF)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/c" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&H6666)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/M" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&HFF00FF)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/m" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&H660066)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/y" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&H666600)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/Y" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&HFFFF00)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/g" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&H6600)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/G" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&HFF00)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/w" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&H666666)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/W" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&HAAAAAA)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/z" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&H333333)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/Z" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&HFFFFFF)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/R" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&HFF0000)
                    TempInt2 = TempInt
                    Switches += 1
                ElseIf Mid(Txt, TempInt, 2) = "/r" Then
                    If TempInt2 <> 0 Then
                        TempStr2 = Mid(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Txt, "/b", ""), "/B", ""), "/g", ""), "/G", ""), "/m", ""), "/M", ""), "/w", ""), "/W", ""), "/y", ""), "/Y", ""), "/z", ""), "/Z", ""), "/c", ""), "/C", ""), "/r", ""), "/R", ""), TempInt2 - Switches * 2, TempInt - TempInt2 - 2)
                        DebugTXT.SelectedText = TempStr2
                    End If
                    DebugTXT.SelectionColor = Color.FromArgb(&H660000)
                    TempInt2 = TempInt
                    Switches += 1
                End If
            End If
        Next
        DebugTXT.SelectedText = Chr(13)
        DebugTXT.ScrollToCaret()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Make sure that every time a map is generated, it chooses a different environment
        Dim RandomNumber As New Random
        Dim RandomEnvironment As Short = RandomNumber.Next(0, CurMapENVIRON.Items.Count)
        CurMapENVIRON.SelectedIndex = RandomEnvironment

        DebugTXT.Text = ""
        ClearMap(0, System.EventArgs.Empty)
        If ClearMapFailed = False Then
            Dim GroundType As Short = 5
            Dim TOTALroomROWS As Integer = 3
            Dim TOTALroomCOLS As Integer = 3
            Dim MINroomSIZE As Integer = 2
            Dim MAXroomSIZE As Integer = 5
            Dim randomnum As New Random
            Dim roomwidth As Integer = 0
            Dim roomheight As Integer = 0
            Dim roomxposition As Integer = 0
            Dim roomyposition As Integer = 0
            Dim RoomSidesx(3, 3) As Integer
            Dim RoomSidesy(3, 3) As Integer
            Dim RoomSidesw(3, 3) As Integer
            Dim roomsidesh(3, 3) As Integer
            Dim curx As Integer, cury As Integer
            Dim tarx As Integer, tary As Integer
            Dim finished As Boolean = False
            Dim xdone As Boolean = False
            Dim ydone As Boolean = False
            Dim added As Boolean = False
            Dim R1e As Boolean = False, R1s As Boolean = False
            Dim R2e As Boolean = False, R2s As Boolean = False
            Dim R3s As Boolean = False
            Dim R4e As Boolean = False, R4s As Boolean = False
            Dim R5e As Boolean = False, R5s As Boolean = False
            Dim R6s As Boolean = False
            Dim R7e As Boolean = False
            Dim R8e As Boolean = False
            Dim ConnectedType As Short = 0
            ConnectedType = randomnum.Next(1, 37)
            If ConnectedType = 1 Then
                R1e = True : R2s = True : R2e = True : R4e = True : R5s = True : R5e = True : R7e = True : R8e = True
            ElseIf ConnectedType = 2 Then
                R1s = True : R2s = True : R3s = True : R4s = True : R4e = True : R5s = True : R5e = True : R6s = True
            ElseIf ConnectedType = 3 Then
                R1e = True : R2s = True : R3s = True : R4e = True : R5s = True : R5e = True : R6s = True : R7e = True
            ElseIf ConnectedType = 4 Then
                R1s = True : R2s = True : R2e = True : R4s = True : R4e = True : R5s = True : R5e = True : R8e = True
            ElseIf ConnectedType = 5 Then
                R1e = True : R2e = True : R3s = True : R4e = True : R4s = True : R5e = True : R7e = True : R8e = True
            ElseIf ConnectedType = 6 Then
                R1e = True : R1s = True : R2e = True : R4e = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 7 Then
                R1s = True : R1e = True : R3s = True : R4e = True : R4s = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 8 Then
                R1s = True : R2s = True : R2e = True : R4s = True : R4e = True : R5e = True : R6s = True : R8e = True
            ElseIf ConnectedType = 9 Then
                R1e = True : R2e = True : R3s = True : R4e = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 10 Then
                R1s = True : R2s = True : R3s = True : R4s = True : R4e = True : R5s = True : R5e = True : R6s = True : R8e = True
            ElseIf ConnectedType = 11 Then
                R1e = True : R2e = True : R2s = True : R3s = True : R4s = True : R4e = True : R5s = True : R5e = True : R7e = True : R8e = True
            ElseIf ConnectedType = 12 Then
                R1e = True : R1s = True : R2s = True : R2e = True : R4e = True : R5s = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 13 Then
                R1s = True : R2e = True : R3s = True : R4s = True : R4e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 14 Then
                R1e = True : R2s = True : R3s = True : R4s = True : R4e = True : R5e = True : R6s = True : R7e = True
            ElseIf ConnectedType = 15 Then
                R1e = True : R2e = True : R2s = True : R3s = True : R4e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 16 Then
                R1s = True : R2s = True : R2e = True : R3s = True : R4e = True : R4s = True : R5s = True : R5e = True : R6s = True
            ElseIf ConnectedType = 17 Then
                R1s = True : R1e = True : R2e = True : R3s = True : R4e = True : R4s = True : R5e = True : R6s = True : R7e = True
            ElseIf ConnectedType = 18 Then
                R1s = True : R1e = True : R2e = True : R4s = True : R4e = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 19 Then
                R1e = True : R2s = True : R2e = True : R4s = True : R4e = True : R5s = True : R6s = True : R8e = True
            ElseIf ConnectedType = 20 Then
                R1s = True : R2e = True : R3s = True : R4e = True : R4s = True : R5e = True : R5s = True : R8e = True
            ElseIf ConnectedType = 21 Then
                R1s = True : R1e = True : R2e = True : R3s = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 22 Then
                R1s = True : R2s = True : R3s = True : R4s = True : R4e = True : R5s = True : R5e = True : R6s = True : R7e = True
            ElseIf ConnectedType = 23 Then
                R1e = True : R2e = True : R3s = True : R4s = True : R4e = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 24 Then
                R1e = True : R1s = True : R2e = True : R3s = True : R4e = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 25 Then
                R1e = True : R2e = True : R2s = True : R4s = True : R5s = True : R5e = True : R6s = True : R7e = True
            ElseIf ConnectedType = 26 Then
                R1s = True : R2s = True : R2e = True : R4e = True : R4s = True : R5e = True : R6s = True : R8e = True
            ElseIf ConnectedType = 27 Then
                R1s = True : R2e = True : R3s = True : R4s = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 28 Then
                R1s = True : R1e = True : R2s = True : R3s = True : R4s = True : R4e = True : R5s = True : R5e = True : R6s = True
            ElseIf ConnectedType = 29 Then
                R1s = True : R1e = True : R2s = True : R2e = True : R3s = True : R4s = True : R5s = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 30 Then
                R1s = True : R1e = True : R2e = True : R3s = True : R4s = True : R4e = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 31 Then
                R1s = True : R1e = True : R2s = True : R3s = True : R5s = True : R5e = True : R7e = True : R8e = True
            ElseIf ConnectedType = 32 Then
                R1s = True : R2s = True : R2e = True : R3s = True : R4e = True : R5s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 33 Then
                R1s = True : R1e = True : R2s = True : R2e = True : R4s = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 34 Then
                R1s = True : R1e = True : R2s = True : R3s = True : R4s = True : R5s = True : R5e = True : R6s = True : R7e = True
            ElseIf ConnectedType = 35 Then
                R1e = True : R2s = True : R2e = True : R3s = True : R4s = True : R4e = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 36 Then
                R1s = True : R1e = True : R2s = True : R2e = True : R4s = True : R4e = True : R5e = True : R6s = True : R7e = True : R8e = True
            ElseIf ConnectedType = 37 Then
                R1e = True : R1s = True : R2s = True : R2e = True : R3s = True : R4s = True : R4e = True : R5s = True : R5e = True : R6s = True : R7e = True : R8e = True
            End If
            For a = 0 To 2 Step 1
                For b = 0 To 2 Step 1
                    roomwidth = randomnum.Next(MINroomSIZE, MAXroomSIZE)
                    roomheight = randomnum.Next(MINroomSIZE, MAXroomSIZE)
                    roomxposition = 1 + a * 4 + randomnum.Next(0, MAXroomSIZE - roomwidth + 1) - 1
                    roomyposition = 1 + b * 4 + randomnum.Next(0, MAXroomSIZE - roomheight + 1) - 1
                    RoomSidesw(a, b) = roomwidth + 1
                    roomsidesh(a, b) = roomheight + 1
                    RoomSidesx(a, b) = roomxposition
                    RoomSidesy(a, b) = roomyposition
                    SND("/cRoom /Z(/C" + LTrim(Str(a + 1)) + "/Z,/C" + LTrim(Str(b + 1)) + "/Z) coordinates: /Z(/C" + LTrim(Str(RoomSidesx(a, b))) + "/Z,/C" + LTrim(Str(RoomSidesy(a, b))) + "/Z) /cWidth: /C" + LTrim(Str(RoomSidesw(a, b))) + " /cHeight: /C" + LTrim(Str(roomsidesh(a, b))))
                    For x = roomxposition To roomxposition + roomwidth Step 1
                        For y = roomyposition To roomyposition + roomheight Step 1
                            If x = roomxposition Or x = roomxposition + roomwidth Then 'north and south walls
                                Map(x, y) = 2
                            ElseIf y = roomyposition Or y = roomyposition + roomheight Then 'east and west walls
                                Map(x, y) = 2
                            Else 'the floor
                                Map(x, y) = 4
                            End If
                        Next
                    Next
                Next
            Next
            For x = 0 To 3 Step 1 'NOTE: draw all cooridors east, no need for west drawing
                For y = 0 To 3 Step 1
                    If x = 0 And y = 0 And R1e = True Or x = 1 And y = 0 And R2e = True Or x = 0 And y = 1 And R4e = True Or x = 1 And y = 1 And R5e = True Or x = 0 And y = 2 And R7e = True Or x = 1 And y = 2 And R8e = True Then 'if x is left of right wall then draw cooridors to the right
                        xdone = False : ydone = False : finished = False
                        curx = RoomSidesx(x, y) + RoomSidesw(x, y) - 2
                        cury = RoomSidesy(x, y) + Math.Round(roomsidesh(x, y) / 2, 0) - 1
                        tarx = RoomSidesx(x + 1, y)
                        tary = RoomSidesy(x + 1, y) + Math.Round(roomsidesh(x + 1, y) / 2, 0)
                        SND("/R" + LTrim(Str(curx)) + "," + LTrim(Str(cury)) + "/G->/R" + LTrim(Str(tarx)) + "," + LTrim(Str(tary)))
                        While finished = False
                            If curx < tarx Then
                                curx += 1
                                Map(curx, cury) = GroundType
                                added = True
                            ElseIf curx > tarx Then
                                curx -= 1
                                Map(curx, cury) = GroundType
                                added = True
                            Else
                                xdone = True
                            End If
                            If added = True Then 'walls for cooridors
                                If Map(curx + 1, cury) < 3 Then Map(curx + 1, cury) = 2
                                If curx - 1 >= 0 Then If Map(curx - 1, cury) < 3 Then Map(curx - 1, cury) = 2
                                If Map(curx, cury + 1) < 3 Then Map(curx, cury + 1) = 2
                                If cury - 1 >= 0 Then If Map(curx, cury - 1) < 3 Then Map(curx, cury - 1) = 2
                                added = False
                            End If
                            If cury < tary Then
                                cury += 1
                                Map(curx, cury) = GroundType
                                added = True
                            ElseIf cury > tary Then
                                cury -= 1
                                Map(curx, cury) = GroundType
                                added = True
                            Else
                                ydone = True
                            End If
                            If added = True Then 'walls for cooridors
                                If Map(curx + 1, cury) < 3 Then Map(curx + 1, cury) = 2
                                If curx - 1 >= 0 Then If Map(curx - 1, cury) < 3 Then Map(curx - 1, cury) = 2
                                If Map(curx, cury + 1) < 3 Then Map(curx, cury + 1) = 2
                                If cury - 1 >= 0 Then If Map(curx, cury - 1) < 3 Then Map(curx, cury - 1) = 2
                                added = False
                            End If
                            If xdone = True And ydone = True Then
                                finished = True
                                Exit While
                            End If
                        End While
                    End If
                    If x = 0 And y = 0 And R1s = True Or x = 1 And y = 0 And R2s = True Or x = 2 And y = 0 And R3s = True Or x = 0 And y = 1 And R4s = True Or x = 1 And y = 1 And R5s = True Or x = 2 And y = 1 And R6s = True Then 'if y is north of southern wall then draw cooridor to south
                        xdone = False : ydone = False : finished = False
                        curx = RoomSidesx(x, y) + RoomSidesw(x, y) - 2
                        cury = RoomSidesy(x, y) + Math.Round(roomsidesh(x, y) / 2, 0) - 1
                        tarx = RoomSidesx(x, y + 1)
                        tary = RoomSidesy(x, y + 1) + Math.Round(roomsidesh(x, y + 1) / 2, 0)
                        SND("/R" + LTrim(Str(curx)) + "," + LTrim(Str(cury)) + "/G->/R" + LTrim(Str(tarx)) + "," + LTrim(Str(tary)))
                        While finished = False
                            If curx < tarx Then
                                curx += 1
                                Map(curx, cury) = GroundType
                                added = True
                            ElseIf curx > tarx Then
                                curx -= 1
                                Map(curx, cury) = GroundType
                                added = True
                            Else
                                xdone = True
                            End If
                            If added = True Then 'walls for cooridors
                                If Map(curx + 1, cury) < 3 Then Map(curx + 1, cury) = 2
                                If curx - 1 >= 0 Then If Map(curx - 1, cury) < 3 Then Map(curx - 1, cury) = 2
                                If Map(curx, cury + 1) < 3 Then Map(curx, cury + 1) = 2
                                If cury - 1 >= 0 Then If Map(curx, cury - 1) < 3 Then Map(curx, cury - 1) = 2
                                added = False
                            End If
                            If cury < tary Then
                                cury += 1
                                Map(curx, cury) = GroundType
                                added = True
                            ElseIf cury > tary Then
                                cury -= 1
                                Map(curx, cury) = GroundType
                                added = True
                            Else
                                ydone = True
                            End If
                            If added = True Then 'walls for cooridors
                                If Map(curx + 1, cury) < 3 Then Map(curx + 1, cury) = 2
                                If curx - 1 >= 0 Then If Map(curx - 1, cury) < 3 Then Map(curx - 1, cury) = 2
                                If Map(curx, cury + 1) < 3 Then Map(curx, cury + 1) = 2
                                If cury - 1 >= 0 Then If Map(curx, cury - 1) <> 5 Then Map(curx, cury - 1) = 2
                                added = False
                            End If
                            If xdone = True And ydone = True Then
                                finished = True
                                Exit While
                            End If
                        End While
                    End If
                Next
            Next
            Dim xish As Integer 'makes the code smaller, easier to read
            Dim yish As Integer 'also makes it smaller
            Dim changed As Boolean = False, finishedit As Boolean = False
            curx = 0 : cury = 0
            Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
            Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
            Dim skip As Boolean = False
            Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
            Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
            For x = 0 To Val(Columns) - 1 Step 1
                For y = 0 To Val(Rows) - 1 Step 1
                    xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                    yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                    xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                    If Map(x, y) = 4 Or Map(x, y) = 1 Then
                        MapEnvironment(x, y) = 0 'inside
                        MapEnvironmentSet(x, y) = True
                    Else
                        MapEnvironment(x, y) = RandomEnvironment
                        MapEnvironmentSet(x, y) = True
                    End If
                    Dim ColorString As String = Replace(SetEnvironmentColor(x, y, MapEnvironment(x, y)), "0x", "#")
                    Dim CustomPen As New Pen(ColorTranslator.FromHtml(ColorString))
                    If Map(x, y) = 2 Then
                        Map(x, y) = 0 'not a map cell
                        canvas.DrawLine(Pens.DarkSlateGray, xish, yish, xishPLUS, yish)
                        canvas.DrawLine(Pens.Black, xishPLUS, yish, xishPLUS, yishPLUS)
                        canvas.DrawLine(Pens.Black, xishPLUS, yishPLUS, xish, yishPLUS)
                        canvas.DrawLine(Pens.DarkSlateGray, xish, yishPLUS, xish, yish)
                    Else
                        Map(x, y) = 1 'is a map cell
                        canvas.DrawLine(CustomPen, xish, yish, xishPLUS, yish)
                        canvas.DrawLine(CustomPen, xishPLUS, yish, xishPLUS, yishPLUS)
                        canvas.DrawLine(CustomPen, xishPLUS, yishPLUS, xish, yishPLUS)
                        canvas.DrawLine(CustomPen, xish, yishPLUS, xish, yish)
                    End If
                Next
            Next
            Dim theexitfont As New Font("Arial", 8)
            Dim theothefont As New Font("Arial", 4)
            For x = 0 To 14 Step 1
                For y = 0 To 14 Step 1
                    If Map(x, y) <> 0 Then
                        If x > 0 Then
                            If Map(x - 1, y) = 1 Then
                                MapW(x, y) = True
                            End If
                        End If
                        If x < 13 Then
                            If Map(x + 1, y) = 1 Then
                                MapE(x, y) = True
                            End If
                        End If
                        If y > 0 Then
                            If Map(x, y - 1) = 1 Then
                                MapN(x, y) = True
                            End If
                        End If
                        If y < 13 Then
                            If Map(x, y + 1) = 1 Then
                                MapS(x, y) = True
                            End If
                        End If
                        xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                        yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                        xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                        yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                        Dim tmp0 As Short = 0
                        MapAcessible(x, y) = True
                        If MapN(x, y) = True Then
                            For tmp0 = 0 To 15 Step 1
                                canvas.DrawString("↑", theexitfont, Brushes.White, xish + 13, yish - 1)
                            Next
                        End If
                        If MapS(x, y) = True Then
                            For tmp0 = 0 To 15 Step 1
                                canvas.DrawString("↓", theexitfont, Brushes.White, xish + 13, yish + 17)
                            Next
                        End If
                        If MapE(x, y) = True Then
                            For tmp0 = 0 To 15 Step 1
                                canvas.DrawString("→", theexitfont, Brushes.White, xish + 18, yish + 8)
                            Next
                        End If
                        If MapW(x, y) = True Then
                            For tmp0 = 0 To 15 Step 1
                                canvas.DrawString("←", theexitfont, Brushes.White, xish, yish + 8)
                            Next
                        End If
                        If MapU(x, y) = True Then
                            For tmp0 = 0 To 15 Step 1
                                canvas.DrawString("up", theothefont, Brushes.White, xish, yish)
                            Next
                        End If
                        If MapD(x, y) = True Then
                            For tmp0 = 0 To 15 Step 1
                                canvas.DrawString("down", theothefont, Brushes.White, xish + 22, yish + 25)
                            Next
                        End If
                    End If
                Next
            Next
            hastrace = False
            repaint()
        Else
            ClearMapFailed = False
        End If
    End Sub
    Public Sub repaint()
        Me.CreateGraphics.DrawImage(pad, 0, 0)
    End Sub
    Private Sub repaint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Me.CreateGraphics.DrawImage(pad, 0, 0)
    End Sub
    Private Sub MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        Dim TheX As Integer = Cursor.Position.X - Me.Left - 10
        Dim TheY As Integer = Cursor.Position.Y - Me.Top - 68
        Dim NEXTX As Integer, NEXTY As Integer
        NEXTX = Math.Ceiling(15 / ((5 * 15) + (32 * 15)) * TheX)
        NEXTY = Math.Ceiling(15 / ((5 * 15) + (32 * 15)) * TheY) - 1
        If NEXTX > 15 Then
            NEXTX = 15
        ElseIf NEXTX <= 1 Then
            NEXTX = 1
        End If
        If NEXTY > 15 Then
            NEXTY = 15
        ElseIf NEXTY <= 1 Then
            NEXTY = 1
        End If
        MouseColumn = NEXTX
        MouseRow = NEXTY
    End Sub
    Private Sub MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
        Dim theexitfont As New Font("Arial", 8)
        Dim theothefont As New Font("Arial", 10)
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        Dim TheX As Integer = Cursor.Position.X - Me.Left - 10
        Dim TheY As Integer = Cursor.Position.Y - Me.Top - 68
        Dim NEXTX As Integer, NEXTY As Integer
        NEXTX = Math.Ceiling(15 / ((5 * 15) + (32 * 15)) * TheX)
        NEXTY = Math.Ceiling(15 / ((5 * 15) + (32 * 15)) * TheY) - 1
        If NEXTX > 15 Then
            Exit Sub
        ElseIf NEXTX < 1 Then
            Exit Sub
        End If
        If NEXTY > 16 Then
            Exit Sub
        ElseIf NEXTY < 1 Then
            Exit Sub
        End If
        If MouseColumn = NEXTX And MouseRow = NEXTY And e.Button = Windows.Forms.MouseButtons.Left And GroupBox1.Enabled = False Then
            NEXTX -= 1 : NEXTY -= 1
            If Map(NEXTX, NEXTY) = 0 And LockSectorCreation.Checked = False And LinkingOnly.Checked = False Then
                Map(NEXTX, NEXTY) = 1
                If CurX = NEXTX And CurY = NEXTY Then CheckBox3.Checked = True
                curxandy.ForeColor = Color.Black
            ElseIf Map(NEXTX, NEXTY) <> 0 And LockSectorDeletion.Checked = False And LinkingOnly.Checked = False Then
                If CurX = NEXTX And CurY = NEXTY Then CheckBox3.Checked = False
                curxandy.ForeColor = Color.Red
                Map(NEXTX, NEXTY) = 0
                MapN(NEXTX, NEXTY) = False
                MapS(NEXTX, NEXTY) = False
                MapE(NEXTX, NEXTY) = False
                MapW(NEXTX, NEXTY) = False
                MapU(NEXTX, NEXTY) = False
                MapD(NEXTX, NEXTY) = False
                'now checking each direction of deleted cell and deleting links to it
                If NEXTY - 1 >= 0 Then
                    MapS(NEXTX, NEXTY - 1) = False
                End If
                If NEXTY + 1 <= 14 Then
                    MapN(NEXTX, NEXTY + 1) = False
                End If
                If NEXTX - 1 >= 0 Then
                    MapE(NEXTX - 1, NEXTY) = False
                End If
                If NEXTX + 1 <= 14 Then
                    MapW(NEXTX + 1, NEXTY) = False
                End If
            End If
            xish = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10
            yish = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10
            xishPLUS = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10 + Val(TheRoomWidth)
            yishPLUS = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10 + Val(TheRoomHeight)
            Dim TMP0 As Byte 'this temporary byte variable is used to recurse and draw an x multiple times to make sure it shows properly
            If Map(NEXTX, NEXTY) <> 0 And MapEnvironmentSet(NEXTX, NEXTY) = False Then 'checks to see if the sector is currently not empty
                MapEnvironment(NEXTX, NEXTY) = Val(Mid(CurMapENVIRON.Text, 1, 2)) 'changes the sector environment to the environment of the CurMapEnviron.selectedIndex value 
                MapEnvironmentSet(NEXTX, NEXTY) = True 'environment has now been set for this sector
                xish = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10
                yish = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10
                For TMP0 = 0 To 15
                    canvas.DrawString("x", theexitfont, Brushes.LightBlue, xish + 21, yish + 19) 'this just shows the editor that this sector has a changed environment since mapload or creation
                Next
            Else
                MapEnvironment(NEXTX, NEXTY) = Val(Mid(CurMapENVIRON.Text, 1, 2)) 'the environment has already changed once, just change the environment to the next environment and forgo drawing the "x"
            End If
            'now draw the sector box as the environment color
            Dim ColorString As String = Replace(SetEnvironmentColor(NEXTX, NEXTY, MapEnvironment(NEXTX, NEXTY)), "0x", "#")
            Dim CustomPen As New Pen(ColorTranslator.FromHtml(ColorString))
            If Map(NEXTX, NEXTY) = 0 Then
                canvas.DrawLine(Pens.DarkSlateGray, xish, yish, xishPLUS, yish)
                canvas.DrawLine(Pens.Black, xishPLUS, yish, xishPLUS, yishPLUS)
                canvas.DrawLine(Pens.Black, xishPLUS, yishPLUS, xish, yishPLUS)
                canvas.DrawLine(Pens.DarkSlateGray, xish, yishPLUS, xish, yish)
            Else
                canvas.DrawLine(CustomPen, xish, yish, xishPLUS, yish)
                canvas.DrawLine(CustomPen, xishPLUS, yish, xishPLUS, yishPLUS)
                canvas.DrawLine(CustomPen, xishPLUS, yishPLUS, xish, yishPLUS)
                canvas.DrawLine(CustomPen, xish, yishPLUS, xish, yish)
            End If
            Dim thexit As Short = NEXTX - 1, theyit As Short = NEXTY - 1
            If thexit < 0 Then thexit += 1
            If theyit < 0 Then theyit += 1
            If NEXTX > 14 Then NEXTX = 14
            If NEXTY > 14 Then NEXTY = 14
            For NEXTX = thexit To thexit + 2 Step 1
                For NEXTY = theyit To theyit + 2 Step 1
                    xish = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10
                    yish = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10
                    xishPLUS = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10 + Val(TheRoomHeight)
                    If NEXTX <= 14 And NEXTY <= 14 And NEXTX >= 0 And NEXTY >= 0 Then
                        If MapN(NEXTX, NEXTY) = True Then
                            For x = 1 To 20 Step 1
                                canvas.DrawString("↑", theexitfont, Brushes.White, xish + 13, yish - 1)
                            Next
                        Else
                            For x = 1 To 20 Step 1
                                canvas.DrawString("↑", theexitfont, Brushes.Black, xish + 13, yish - 1)
                            Next
                        End If
                    End If
                    If NEXTX <= 14 And NEXTY <= 14 And NEXTX >= 0 And NEXTY >= 0 Then
                        If MapS(NEXTX, NEXTY) = True Then
                            For x = 1 To 20 Step 1
                                canvas.DrawString("↓", theexitfont, Brushes.White, xish + 13, yish + 17)
                            Next
                        Else
                            For x = 1 To 20 Step 1
                                canvas.DrawString("↓", theexitfont, Brushes.Black, xish + 13, yish + 17)
                            Next
                        End If
                    End If
                    If NEXTX <= 14 And NEXTY <= 14 And NEXTX >= 0 And NEXTY >= 0 Then
                        If MapE(NEXTX, NEXTY) = True Then
                            For x = 1 To 20 Step 1
                                canvas.DrawString("→", theexitfont, Brushes.White, xish + 18, yish + 8)
                            Next
                        Else
                            For x = 1 To 20 Step 1
                                canvas.DrawString("→", theexitfont, Brushes.Black, xish + 18, yish + 8)
                            Next
                        End If
                    End If
                    If NEXTX <= 14 And NEXTY <= 14 And NEXTX >= 0 And NEXTY >= 0 Then
                        If MapW(NEXTX, NEXTY) = True Then
                            For x = 1 To 20 Step 1
                                canvas.DrawString("←", theexitfont, Brushes.White, xish, yish + 8)
                            Next
                        Else
                            For x = 1 To 20 Step 1
                                canvas.DrawString("←", theexitfont, Brushes.Black, xish, yish + 8)
                            Next
                        End If
                    End If
                Next
            Next
            repaint()
        ElseIf MouseColumn = NEXTX And MouseRow = NEXTY And e.Button = Windows.Forms.MouseButtons.Right Or MouseColumn = NEXTX And MouseRow = NEXTY And GroupBox1.Enabled = True Then
            xish = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10
            yish = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10
            xishPLUS = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10 + Val(TheRoomWidth)
            yishPLUS = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10 + Val(TheRoomHeight)
            For x = 1 To 15
                canvas.DrawString("o", theexitfont, Brushes.Black, xish + 12, yish + 8)
            Next
            NEXTX -= 1 : CurX = NEXTX
            NEXTY -= 1 : CurY = NEXTY
            If Map(CurX, CurY) = 0 Then
                curxandy.ForeColor = Color.Red
            Else
                curxandy.ForeColor = Color.Black
            End If
            Dim AnyMapExits As Boolean = False
            If MapNorth(CurX, CurY) <> "0" Then
                If AnyMapExits = False Then
                    AnyMapExits = True
                    ConnectLabel.Text = "North" + MapNorth(CurX, CurY)
                Else
                    ConnectLabel.Text += ",North" + MapNorth(CurX, CurY)
                End If
            End If
            If MapSouth(CurX, CurY) <> "0" Then
                If AnyMapExits = False Then
                    AnyMapExits = True
                    ConnectLabel.Text = "South" + MapSouth(CurX, CurY)
                Else
                    ConnectLabel.Text += ",South" + MapSouth(CurX, CurY)
                End If
            End If
            If MapEast(CurX, CurY) <> "0" Then
                If AnyMapExits = False Then
                    AnyMapExits = True
                    ConnectLabel.Text = "East" + MapEast(CurX, CurY)
                Else
                    ConnectLabel.Text += ",East" + MapEast(CurX, CurY)
                End If
            End If
            If MapWest(CurX, CurY) <> "0" Then
                If AnyMapExits = False Then
                    AnyMapExits = True
                    ConnectLabel.Text = "West" + MapWest(CurX, CurY)
                Else
                    ConnectLabel.Text += ",West" + MapWest(CurX, CurY)
                End If
            End If
            If MapUp(CurX, CurY) <> "0" Then
                If AnyMapExits = False Then
                    AnyMapExits = True
                    ConnectLabel.Text = "Up" + MapUp(CurX, CurY)
                Else
                    ConnectLabel.Text += ",Up" + MapUp(CurX, CurY)
                End If
            End If
            If MapDown(CurX, CurY) <> "0" Then
                If AnyMapExits = False Then
                    AnyMapExits = True
                    ConnectLabel.Text = "Down" + MapDown(CurX, CurY)
                Else
                    ConnectLabel.Text += ",Down" + MapDown(CurX, CurY)
                End If
            End If
            If AnyMapExits = False Then
                ConnectLabel.Text = "Not Connected"
            End If
            CurSectorName.Text = MapDesc(CurX, CurY)
            CurSectorDescription.Text = MapDescription(CurX, CurY)
            If MapAcessible(CurX, CurY) = 0 Then CheckBox3.Checked = False Else CheckBox3.Checked = True
            If MapSafe(CurX, CurY) = 0 Then CheckBox7.Checked = False Else CheckBox7.Checked = True
            'now before we change teh environment box we need to make sure that it doesn't trigger the repaint()
            'method. When the boxes value changes, it re-calibrates the color of the PAD, in this case, this isn't
            'necessary
            PreventRedraw = True
            CurMapENVIRON.Text = CurMapENVIRON.Items(MapEnvironment(CurX, CurY))

            curxandy.Text = LTrim(Str(CurX + 1)) + "," + LTrim(Str(CurY + 1))
            xish = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10
            yish = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10
            xishPLUS = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10 + Val(TheRoomWidth)
            yishPLUS = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10 + Val(TheRoomHeight)
            canvas.DrawString("o", theexitfont, Brushes.LightGreen, xish + 12, yish + 8)
            repaint()
            Mobilelist.Items.Clear()
            PropList.Items.Clear()
            Dim Tempstr2 As String = "", MobVNUM As String = "", tmpnum As Integer, MobEMOTE As String = "", LastEND As Integer = 0
            For x = 1 To Len(MapMobiles(CurX, CurY)) + 2 Step 1
                If Mid("," + MapMobiles(CurX, CurY) + ",", x, 1) = "," Then
                    If Mid(MapMobiles(CurX, CurY) + ",", 1 + Len(Tempstr2) + 1, 1) <> "." Then
                        Tempstr2 += ","
                        For tmpnum = x To Len(MapMobiles(CurX, CurY)) + 2 Step 1
                            If Mid("," + MapMobiles(CurX, CurY), tmpnum, 1) = "." Then
                                MobVNUM = Replace(Mid("," + MapMobiles(CurX, CurY), x + 1, tmpnum - 1 - x), ",", "")
                                LastEND = tmpnum
                                Exit For
                            End If
                        Next
                        If MobVNUM <> "" Then
                            For tmpnum = LastEND To Len(MapMobiles(CurX, CurY)) + 1 Step 1
                                If Mid(MapMobiles(CurX, CurY) + ",", tmpnum, 1) = "," Then
                                    MobEMOTE = Mid(MapMobiles(CurX, CurY), LastEND, tmpnum - LastEND)
                                    Exit For
                                End If
                            Next
                        End If
                        If MobVNUM <> "" Then
                            MapEditorAddMobile.LoadMob(MobVNUM)
                            Mobilelist.Items.Add(MobVNUM + ". " + MapEditorAddMobile.MobData_SHORT + "<" + MapEditorAddMobile.MobData_MNAME + ">{" + MobEMOTE + "}")
                        Else
                            Exit For
                        End If
                    ElseIf x < Len(MapMobiles(CurX, CurY)) + 2 Then
                        For tmpnum = x To Len(MapMobiles(CurX, CurY)) + 2 Step 1
                            If Mid("," + MapMobiles(CurX, CurY), tmpnum, 1) = "." Then
                                MobVNUM = Replace(Mid("," + MapMobiles(CurX, CurY), x + 1, tmpnum - 1 - x), ",", "")
                                LastEND = tmpnum
                                Exit For
                            End If
                        Next
                        If MobVNUM <> "" Then
                            For tmpnum = LastEND To Len(MapMobiles(CurX, CurY)) + 1 Step 1
                                If Mid(MapMobiles(CurX, CurY) + ",", tmpnum, 1) = "," Then
                                    MobEMOTE = Mid(MapMobiles(CurX, CurY), LastEND, tmpnum - LastEND)
                                    Exit For
                                End If
                            Next
                        End If
                        If MobVNUM <> "" Then
                            MapEditorAddMobile.LoadMob(MobVNUM)
                            Mobilelist.Items.Add(MobVNUM + ". " + MapEditorAddMobile.MobData_SHORT + "<" + MapEditorAddMobile.MobData_MNAME + ">{" + MobEMOTE + "}")
                        Else
                            Exit For
                        End If
                    End If
                End If
            Next
            Dim tmp0 As Integer, tmp1 As Integer, sint As Integer
            Dim xstr As String = "," + MapProps(CurX, CurY)
            For tmp0 = 1 To Len(xstr) Step 1
                If Mid(xstr, tmp0, 1) = "," Then
                    sint = tmp0 + 1
                ElseIf Mid(xstr, tmp0, 1) = "." Then
                    If Mid(xstr, sint, tmp0 - sint) = "?" Then
                        For tmp1 = tmp0 To Len(xstr) Step 1
                            If Mid(xstr, tmp1, 1) = "]" Then
                                MapEditorAddProp.LoadItem(Mid(xstr, sint + 3, tmp1 - sint - 3))
                                PropList.Items.Add("?. " + Mid(xstr, sint + 3, tmp1 - sint - 3))
                                tmp0 = tmp1
                                Exit For
                            End If
                        Next
                    Else
                        MapEditorAddProp.LoadItem(Mid(xstr, sint, tmp0 - sint))
                        PropList.Items.Add(Mid(xstr, sint, tmp0 - sint) + ". " + MapEditorAddProp.ItemData_SHORT)
                    End If
                End If
            Next
        Else
            If LockSectorLinking.Checked = False And MouseColumn <= NEXTX + 1 And MouseColumn >= NEXTX - 1 And MouseRow <= NEXTY + 1 And MouseRow >= NEXTY - 1 And Map(MouseColumn - 1, MouseRow - 1) <> 0 And Map(NEXTX - 1, NEXTY - 1) <> 0 Then
                If MouseColumn <> NEXTX And MouseRow <> NEXTY Then
                    'sectors can't be linked diagnally, fail
                Else
                    Dim FIRSTX As Short = MouseColumn - 1
                    Dim FIRSTY As Short = MouseRow - 1
                    NEXTX -= 1
                    NEXTY -= 1
                    If FIRSTX > NEXTX Then
                        If MapW(FIRSTX, FIRSTY) = True And MapE(NEXTX, NEXTY) = True Then 'if connection already exists, then remove connection instead of creating
                            MapW(FIRSTX, FIRSTY) = False
                            MapE(NEXTX, NEXTY) = False
                        Else
                            MapW(FIRSTX, FIRSTY) = True
                            MapE(NEXTX, NEXTY) = True
                        End If
                    ElseIf FIRSTX < NEXTX Then
                        If MapE(FIRSTX, FIRSTY) = True And MapW(NEXTX, NEXTY) = True Then 'if connection already exists, then remove connection instead of creating
                            MapE(FIRSTX, FIRSTY) = False
                            MapW(NEXTX, NEXTY) = False
                        Else
                            MapE(FIRSTX, FIRSTY) = True
                            MapW(NEXTX, NEXTY) = True
                        End If
                    ElseIf FIRSTY > NEXTY Then
                        If MapN(FIRSTX, FIRSTY) = True And MapS(NEXTX, NEXTY) = True Then 'if connection already exists, then remove connection instead of creating
                            MapN(FIRSTX, FIRSTY) = False
                            MapS(NEXTX, NEXTY) = False
                        Else
                            MapN(FIRSTX, FIRSTY) = True
                            MapS(NEXTX, NEXTY) = True
                        End If
                    ElseIf FIRSTY < NEXTY Then
                        If MapS(FIRSTX, FIRSTY) = True And MapN(NEXTX, NEXTY) = True Then 'if connection already exists, then remove connection instead of creating
                            MapS(FIRSTX, FIRSTY) = False
                            MapN(NEXTX, NEXTY) = False
                        Else
                            MapS(FIRSTX, FIRSTY) = True
                            MapN(NEXTX, NEXTY) = True
                        End If
                    End If
                    Dim thexit As Short = NEXTX - 1, theyit As Short = NEXTY - 1
                    If thexit < 0 Then thexit += 1
                    If theyit < 0 Then theyit += 1
                    If NEXTX > 14 Then NEXTX = 14
                    If NEXTY > 14 Then NEXTY = 14
                    For NEXTX = thexit To thexit + 2 Step 1
                        For NEXTY = theyit To theyit + 2 Step 1
                            xish = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10
                            yish = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10
                            xishPLUS = Val(TheRoomWidth) * NEXTX + Val(ColumnsSpace) * NEXTX + 10 + Val(TheRoomWidth)
                            yishPLUS = Val(TheRoomHeight) * NEXTY + Val(RowSpace) * NEXTY + 10 + Val(TheRoomHeight)
                            If NEXTX <= 14 And NEXTY <= 14 And NEXTX >= 0 And NEXTY >= 0 Then
                                If MapN(NEXTX, NEXTY) = True Then
                                    For x = 1 To 20 Step 1
                                        canvas.DrawString("↑", theexitfont, Brushes.White, xish + 13, yish - 1)
                                    Next
                                Else
                                    For x = 1 To 20 Step 1
                                        canvas.DrawString("↑", theexitfont, Brushes.Black, xish + 13, yish - 1)
                                    Next
                                End If
                            End If
                            If NEXTX <= 14 And NEXTY <= 14 And NEXTX >= 0 And NEXTY >= 0 Then
                                If MapS(NEXTX, NEXTY) = True Then
                                    For x = 1 To 20 Step 1
                                        canvas.DrawString("↓", theexitfont, Brushes.White, xish + 13, yish + 17)
                                    Next
                                Else
                                    For x = 1 To 20 Step 1
                                        canvas.DrawString("↓", theexitfont, Brushes.Black, xish + 13, yish + 17)
                                    Next
                                End If
                            End If
                            If NEXTX <= 14 And NEXTY <= 14 And NEXTX >= 0 And NEXTY >= 0 Then
                                If MapE(NEXTX, NEXTY) = True Then
                                    For x = 1 To 20 Step 1
                                        canvas.DrawString("→", theexitfont, Brushes.White, xish + 18, yish + 8)
                                    Next
                                Else
                                    For x = 1 To 20 Step 1
                                        canvas.DrawString("→", theexitfont, Brushes.Black, xish + 18, yish + 8)
                                    Next
                                End If
                            End If
                            If NEXTX <= 14 And NEXTY <= 14 And NEXTX >= 0 And NEXTY >= 0 Then
                                If MapW(NEXTX, NEXTY) = True Then
                                    For x = 1 To 20 Step 1
                                        canvas.DrawString("←", theexitfont, Brushes.White, xish, yish + 8)
                                    Next
                                Else
                                    For x = 1 To 20 Step 1
                                        canvas.DrawString("←", theexitfont, Brushes.Black, xish, yish + 8)
                                    Next
                                End If
                            End If
                        Next
                    Next
                End If
            Else
                'sector dragged to is too far away, fail
            End If
            repaint()
        End If
    End Sub
    Private Sub SaveTheMap(ByVal SaveAsNew As Boolean)
        Dim TheLine As String = "", VNUM As Short = 0, Filler As String = ""
        'MapOutput is merely everything except the sectorlist node
        'MapBase is what the sectorlist node is saved to, and then added to the mapfile after the MapOutput is saved.
        Dim MapOutput, MapBase As String
        'if SaveasNew is true then the mapfile is going to be created instead of overwritten.
        If SaveAsNew = True Then TotalMaps += 1
        'The following is merely fluff. The map is only "created" if the map doesn't currently exist,
        'not to mention that the map if actually created isn't created here, but created further below
        'at the end of the process during saving. The decision to move this up here was due to visual
        'comprehension of the debug output.
        If My.Computer.FileSystem.FileExists(Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", Replace(CurMap.Text + ".TG", " ", ""))) = False Then
            SND("/YMap Created! /z[" + Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", Replace(CurMap.Text + ".TG", " ", "")) + "]")
        End If
        'Here we'll create the XML header for the map database file. This header will include
        'some basic descriptions of the contents of the file for those who happen to open the file
        'to edit it manually instead of using the map editor.
        SND("/yCreating XML header...")
        MapOutput = "<?xml version=" + Chr(34) + "1.0" + Chr(34) + " encoding=" + Chr(34) + "UTF-8" + Chr(34) + "?>" + Chr(13)
        MapOutput += "<?xml-stylesheet type=" + Chr(34) + "text/xsl" + Chr(34) + " href=" + Chr(34) + "../../../Map.xsl" + Chr(34) + "?>" + Chr(13)
        'Here we'll show the map name which is grabbed from the PHP searcher in the O:DB. We also detail the licensing briefly
        MapOutput += "<!-- <title>Map : " + LTrim(RTrim(CurMap.Text)) + "</title>" + Chr(13)
        MapOutput += "   The maps databases were converted from Terminal Groupings (.TG)" + Chr(13)
        MapOutput += "   to eXtensible Markup Language (.xml) starting on 6/23/11 by" + Chr(13)
        MapOutput += "   Nathaniel Inman of The Other Experiment Studio @" + Chr(13)
        MapOutput += "   www.theoestudio.com" + Chr(13)
        MapOutput += "   " + LTrim(RTrim(CurMap.Text)) + " was created on " + Date.UtcNow.Day.ToString + "/" + Date.UtcNow.Month.ToString + "/" + Date.UtcNow.Year.ToString + Chr(13)
        MapOutput += "   All contents within are licensed under GPLv3" + Chr(13)
        MapOutput += "-->" + Chr(13)
        'The map database file actually starts here, we start with the map name and creator which is grabbed from the O:DB.
        SND("/yInitializing nodes...")
        SND("/y Creating map node...")
        MapOutput += "<map name=" + Chr(34) + LTrim(RTrim(CurMap.Text)) + Chr(34) + " creator=" + Chr(34) + LTrim(RTrim(MapCreator.Text)) + Chr(34) + ">" + Chr(13)
        SND("/y Creating description node...")
        MapOutput += "  <description>" + LTrim(RTrim(Notes.Text)) + "</description>" + Chr(13)
        MapOutput += "  <!-- Environment mapping shows first the VNUM of the sector and" + Chr(13)
        MapOutput += "       the environment type number after the colon. You can visually" + Chr(13)
        MapOutput += "       see quite a bit in the environment map below. VNUMS can go" + Chr(13)
        MapOutput += "       up to 225 naturally as a 15x15 map has an area of 225. VNUM's" + Chr(13)
        MapOutput += "       are used as sector ID's and are unique per map, such that if you" + Chr(13)
        MapOutput += "       wanted to teleport to a different map, you would have to specify" + Chr(13)
        MapOutput += "       the maps vnum as well as the sector vnum." + Chr(13)
        MapOutput += "" + Chr(13)
        MapOutput += "       Environment type numbers range from 0 to 101. For a detailed" + Chr(13)
        MapOutput += "       description of these environments, refer to their perspective" + Chr(13)
        MapOutput += "       database file 'Environments.xml'" + Chr(13)
        MapOutput += "   -->" + Chr(13)
        'Now we start the environment mapping which contains the vnums and environment data per sector
        SND("/y Creating environmentmap node...")
        MapOutput += "   <environmentmap>" + Chr(13)
        For y = 0 To 14 Step 1 'there are fifteen lines starting at 0 to 14
            TheLine += "        <line>" 'Time to start a new line.
            For x = 0 To 14 Step 1 'step through the map x axis and append the environment and vnum according to the pattern (VNUM,ENVIRONMENT,) even on the last line (VNUM,ENVIRONMENT)
                If Map(x, y) = 0 Then 'found a blank line, vnums (0=blank) and environment (100=blank) are still important
                    If x = 14 Then
                        TheLine += "0,100,</line>" 'You've reached the end of the line, make sure you add the ending tag
                    Else
                        TheLine += "0,100,"
                    End If
                Else
                    VNUM += 1
                    If x = 14 Then
                        TheLine += LTrim(Str(VNUM)) + "," + AddZeros(LTrim(Str(MapEnvironment(x, y))), 3) + ",</line>"
                    Else
                        TheLine += LTrim(Str(VNUM)) + "," + AddZeros(LTrim(Str(MapEnvironment(x, y))), 3) + ","
                    End If
                End If
            Next
            SND(TheLine)
            MapOutput += TheLine + Chr(13)
            TheLine = ""
        Next
        MapOutput += "	</environmentmap>" + Chr(13)
        MapOutput += "	<!-- Exit mapping shows the different exits per sector of the current map." + Chr(13)
        MapOutput += "		 These values are located within the current sector, but this allows" + Chr(13)
        MapOutput += "		 a quicker view of the entire map without processing overhead. These" + Chr(13)
        MapOutput += "		 are space sensitive.-->" + Chr(13)
        MapOutput += "	<exitmap>" + Chr(13)
        SND("/y Creating exitmap node...")
        VNUM = 0 'set the VNUM back to zero and prepare to recurse the sectors again, this time to detail the sectors fully and prepare an exit map.
        Dim NorthExit As String = "0", SouthExit As String = "0", EastExit As String = "0", WestExit As String = "0", UpExit As String = "0", DownExit As String = "0"
        For y = 0 To 14 Step 1 'recurse through the maps rows
            If y < 9 Then TheLine += " "
            TheLine += "		<line>"
            For x = 0 To 14 Step 1 'recurse through the maps x columns, they are appended to "TheLine" until the line reaches it's end, then the for exits and pushes to the next y row
                'if the current sector is 2, that means the sector is empty.
                'Now we detect whether the current recursive sector is empty, and if it ISN"T then we increase the VNUM by one
                'and add to the sectorlist node the next sector.
                Dim MapDescriptionAdd As String, MapSafeRoom As String = MapSafe(x, y)
                'Find out whether the current sector is a safe room and convert the shortint from 0 and 1 to False and True strings.
                If MapSafeRoom = "1" Then MapSafeRoom = "True" Else MapSafeRoom = "False"
                'The following displays the current sector tag which contains the saferoom flag
                If Map(x, y) <> 0 Then
                    VNUM += 1
                    MapBase += "		<sector number=" + Chr(34) + LTrim(Str(VNUM)) + Chr(34) + " saferoom=" + Chr(34) + MapSafeRoom + Chr(34) + " accessible=" + Chr(34) + Replace(Replace(LTrim(Str(MapAcessible(x, y))), "0", "False"), "1", "True") + Chr(34) + ">" + Chr(13)
                End If
                MapDescriptionAdd = ""
                If MapN(x, y) = True And Map(x, y) <> 0 Then
                    TheLine += "N"
                    If MapNOffMap(x, y) = True Then
                        NorthExit = MapNorth(x, y)
                    Else
                        NorthExit = MapNumber(x, y - 1)
                        MapDescriptionAdd += " " + MapDesc(x, y - 1) + " is to the North."
                    End If
                Else
                    NorthExit = "0"
                    TheLine += " "
                End If
                If MapS(x, y) = True And Map(x, y) <> 0 Then
                    TheLine += "S"
                    If MapSOffMap(x, y) = True Then
                        SouthExit = MapSouth(x, y)
                    Else
                        SouthExit = MapNumber(x, y + 1)
                        MapDescriptionAdd += " " + MapDesc(x, y + 1) + " is to the South."
                    End If
                Else
                    SouthExit = "0"
                    TheLine += " "
                End If
                If MapE(x, y) = True And Map(x, y) <> 0 Then
                    TheLine += "E"
                    If MapEOffMap(x, y) = True Then
                        EastExit = MapEast(x, y)
                    Else
                        EastExit = MapNumber(x + 1, y)
                        MapDescriptionAdd += " " + MapDesc(x + 1, y) + " is to the East."
                    End If
                Else
                    EastExit = "0"
                    TheLine += " "
                End If
                If MapW(x, y) = True And Map(x, y) <> 0 Then
                    TheLine += "W"
                    If MapWOffMap(x, y) = True Then
                        WestExit = MapWest(x, y)
                    Else
                        WestExit = MapNumber(x - 1, y)
                        MapDescriptionAdd += " " + MapDesc(x - 1, y) + " is to the West."
                    End If
                Else
                    WestExit = "0"
                    TheLine += " "
                End If
                If MapU(x, y) = True And Map(x, y) <> 0 Then
                    TheLine += "U"
                    UpExit = MapUp(x, y)
                    MapDescriptionAdd += " " + MapUpLong(x, y) + " is upwards."
                Else
                    UpExit = "0"
                    TheLine += " "
                End If
                If MapD(x, y) = True And Map(x, y) <> 0 Then
                    If x = 14 Then
                        TheLine += "D,</line>" 'Down is at the end of the line, make sure you append the closing tag of the line
                    Else
                        TheLine += "D,"
                    End If
                    DownExit = MapDown(x, y)
                    MapDescriptionAdd += " " + MapDownLong(x, y) + " is downwards."
                Else
                    DownExit = "0"
                    If x = 14 Then
                        TheLine += " ,</line>" 'Down is at the end of the line, make sure you append the closing tag of the line
                    Else
                        TheLine += " ,"
                    End If
                End If
                If Map(x, y) <> 0 Then
                    'The following displays the current exit tag within the sector tag, there is no text() 
                    MapBase += "			<exits east=" + Chr(34) + EastExit + Chr(34) + " west=" + Chr(34) + WestExit + Chr(34)
                    MapBase += " north=" + Chr(34) + NorthExit + Chr(34) + " south=" + Chr(34) + SouthExit + Chr(34) + " up=" + Chr(34) + UpExit + Chr(34)
                    MapBase += " down=" + Chr(34) + DownExit + Chr(34) + "></exits>" + Chr(13)
                    'The following displays the title of the sector
                    MapBase += "			<title>" + MapDesc(x, y) + "</title>" + Chr(13)
                    'The following displays the sector description
                    MapBase += "			<description>/z" + RTrim(Replace(Replace(MapDescription(x, y), "/z", ""), "  ", " ")) + "</description>" + Chr(13)
                    'The following displays the sector props
                    MapBase += "			<props>" + MapProps(x, y) + "</props>" + Chr(13)
                    'The following displays the sector characters
                    MapBase += "			<characters>" + MapMobiles(x, y) + "</characters>" + Chr(13)
                    'The following displays the sectors dropped items - currently not in use
                    MapBase += "			<droppeditems></droppeditems>" + Chr(13)
                    MapBase += "		</sector>" + Chr(13)
                End If
            Next
            SND(TheLine)
            MapOutput += TheLine + Chr(13)
            TheLine = ""
        Next
        MapOutput += "	</exitmap>" + Chr(13)
        MapOutput += "	<!-- Sectorlist contains multiple sectors. 'location' & 'exits' tags text()" + Chr(13)
        MapOutput += "		 will never carry a value that is parsed, therefor programmer notes or" + Chr(13)
        MapOutput += "		 descriptions may be appended here without any harm. location variables" + Chr(13)
        MapOutput += "		 are only necessary to quickly backtrace the entire location of a sector" + Chr(13)
        MapOutput += "		 without having to load the parent area, parent province, etc to gather" + Chr(13)
        MapOutput += "		 these variables. -->" + Chr(13)
        SND("/y Creating sectorlist node...")
        MapOutput += "	<sectorlist>" + Chr(13)
        SND("/y Creating sector nodes...")
        MapOutput += MapBase
        SND("/y Closing sectorlist node...")
        MapOutput += "	</sectorlist>" + Chr(13)
        MapOutput += "</map>"
        SND("/G XML file compiled correctly!")
        'fs is the filestream used to save the mapdata to it's perspective eXtensible Markup Language file. This XML file
        'will then be read by PLOS and the O:DB which displays the maps online using XSLT. These files were converted from
        'Terminal Groupings on July 7th, 2011.
        Dim fs As FileStream
        'Now see if the map already exists, the maps will be in the same location as the AtlasNodes data file
        'so go ahead and replace the filename of the AtlasNodes with the filename of the map to locate whether
        'the file is in existance, and then if it isn't create it. If the file DOES exist then replace it
        'accordingly.
        If FileExists(Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", Replace(CurMap.Text + ".xml", " ", ""))) = False Then
            bAns = SaveTextToFile(MapOutput, Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", Replace(CurMap.Text + ".xml", " ", "")), sErr)
            SND("/YMap file created!")
        Else
            If SaveAsNew = False Then
                SND("/YOverwriting map file!")
                bAns = SaveTextToFile(MapOutput, Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", Replace(CurMap.Text + ".xml", " ", "")), sErr)
            Else
                'This shouldn't occur, and is merely a catch statement incase the map is being accessed concurrently
                'elsewhere on the computer or by a networked user.
                SND("/RMap already exists! Cannot overwrite, delete existing map first.")
            End If
        End If
        'SND("/zUpdating map header...")
        'saving map header
        'bAns = SaveTextToFile(AtlasNodes, Debugger.DirAtlasNodes, sErr)
        SND("/YMap created successfully!")
    End Sub
    Private Sub SectorNameChange(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CurSectorName.KeyUp
        MapDesc(CurX, CurY) = CurSectorName.Text
        Dim tmp0 As Short
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        Dim theexitfont As New Font("Arial", 8)
        If Map(CurX, CurY) <> 2 And MapNameSet(CurX, CurY) = False Then
            xish = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10
            yish = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10
            xishPLUS = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10 + Val(TheRoomWidth)
            yishPLUS = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10 + Val(TheRoomHeight)
            For tmp0 = 0 To 15
                canvas.DrawString("x", theexitfont, Brushes.LightYellow, xish + 2, yish - 1)
            Next
            MapNameSet(CurX, CurY) = True
        End If
        repaint()
    End Sub
    Private Sub SectorDescriptionChange(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CurSectorDescription.KeyUp
        MapDescription(CurX, CurY) = CurSectorDescription.Text
        Dim tmp0 As Short
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        Dim theexitfont As New Font("Arial", 8)
        If Map(CurX, CurY) <> 2 And MapDescriptionSet(CurX, CurY) = False Then
            xish = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10
            yish = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10
            xishPLUS = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10 + Val(TheRoomWidth)
            yishPLUS = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10 + Val(TheRoomHeight)
            For tmp0 = 0 To 15
                canvas.DrawString("x", theexitfont, Brushes.LightGreen, xish + 21, yish - 1)
            Next
            MapDescriptionSet(CurX, CurY) = True
        End If
        repaint()
    End Sub
    Private Sub ClearMap(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If FirstOpen = False And ConfirmIt.Checked = False Then
            If MessageBox.Show("Are you sure you want to clear the entire map? This will delete everything you're currently working on in Map Editor.", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.OK Then
                Dim xish As Integer 'makes the code smaller, easier to read
                Dim yish As Integer 'also makes it smaller
                Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
                Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
                Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
                Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
                Dim theexitfont As New Font("Arial", 8)
                Dim tmp0 As Single
                canvas.FillRectangle(Brushes.Black, 0, 0, xishPLUS + 19, yishPLUS + 18)
                For x = 0 To 14
                    For y = 0 To 14
                        xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                        yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                        xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                        yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                        MapDesc(x, y) = "An Empty Room"
                        MapDescription(x, y) = "You are here."
                        Map(x, y) = 2
                        MapN(x, y) = False
                        MapNorth(x, y) = 0
                        MapNOffMap(x, y) = False
                        MapS(x, y) = False
                        MapSouth(x, y) = 0
                        MapSOffMap(x, y) = False
                        MapE(x, y) = False
                        MapEast(x, y) = 0
                        MapEOffMap(x, y) = False
                        MapW(x, y) = False
                        MapWest(x, y) = 0
                        MapWOffMap(x, y) = False
                        MapU(x, y) = False
                        MapUp(x, y) = 0
                        MapD(x, y) = False
                        MapDown(x, y) = 0
                        canvas.DrawLine(Pens.DarkSlateGray, xish, yish, xishPLUS, yish)
                        canvas.DrawLine(Pens.Black, xishPLUS, yish, xishPLUS, yishPLUS)
                        canvas.DrawLine(Pens.Black, xishPLUS, yishPLUS, xish, yishPLUS)
                        canvas.DrawLine(Pens.DarkSlateGray, xish, yishPLUS, xish, yish)
                        MapAcessible(x, y) = 0
                        MapEnvironment(x, y) = 100
                        MapDescriptionSet(x, y) = False
                        MapNameSet(x, y) = False
                        MapEnvironmentSet(x, y) = False
                    Next
                Next
                repaint()
            Else
                ClearMapFailed = True
            End If
        Else
            Dim xish As Integer 'makes the code smaller, easier to read
            Dim yish As Integer 'also makes it smaller
            Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
            Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
            Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
            Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
            Dim theexitfont As New Font("Arial", 8)
            Dim tmp0 As Single
            canvas.FillRectangle(Brushes.Black, 0, 0, xishPLUS + 19, yishPLUS + 18)
            For x = 0 To 14
                For y = 0 To 14
                    xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                    yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                    xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                    MapDesc(x, y) = "An Empty Room"
                    MapDescription(x, y) = "You are here."
                    Map(x, y) = 2
                    MapN(x, y) = False
                    MapNorth(x, y) = 0
                    MapNOffMap(x, y) = False
                    MapS(x, y) = False
                    MapSouth(x, y) = 0
                    MapSOffMap(x, y) = False
                    MapE(x, y) = False
                    MapEast(x, y) = 0
                    MapEOffMap(x, y) = False
                    MapW(x, y) = False
                    MapWest(x, y) = 0
                    MapWOffMap(x, y) = False
                    MapU(x, y) = False
                    MapUp(x, y) = 0
                    MapD(x, y) = False
                    MapDown(x, y) = 0
                    canvas.DrawLine(Pens.DarkSlateGray, xish, yish, xishPLUS, yish)
                    canvas.DrawLine(Pens.Black, xishPLUS, yish, xishPLUS, yishPLUS)
                    canvas.DrawLine(Pens.Black, xishPLUS, yishPLUS, xish, yishPLUS)
                    canvas.DrawLine(Pens.DarkSlateGray, xish, yishPLUS, xish, yish)
                    MapAcessible(x, y) = 0
                    MapEnvironment(x, y) = 100
                    MapDescriptionSet(x, y) = False
                    MapNameSet(x, y) = False
                    MapEnvironmentSet(x, y) = False
                Next
            Next
            repaint()
            FirstOpen = False
        End If
    End Sub
    Private Sub ChangeCheck(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SectorExitArrows.CheckedChanged, CheckBox1.CheckedChanged
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        Dim theexitfont As New Font("Arial", 8)
        Dim tmp0 As Single
        If sender.Equals(SectorExitArrows) = True Then
            If SectorExitArrows.Checked = True Then CheckBox1.Checked = True
            If SectorExitArrows.Checked = False Then CheckBox1.Checked = False
        End If
        If sender.Equals(CheckBox1) = True Then
            If CheckBox1.Checked = True Then SectorExitArrows.Checked = True
            If CheckBox1.Checked = False Then SectorExitArrows.Checked = False
        End If
        If SectorExitArrows.Checked = False Or CheckBox1.Checked = False Then
            For x = 0 To 14
                For y = 0 To 14
                    xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                    yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                    xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                    If MapN(x, y) = True Then
                        For tmp0 = 1 To 20 Step 1
                            canvas.DrawString("↑", theexitfont, Brushes.Black, xish + 13, yish - 1)
                        Next
                    End If
                    If MapS(x, y) = True Then
                        For tmp0 = 1 To 20 Step 1
                            canvas.DrawString("↓", theexitfont, Brushes.Black, xish + 13, yish + 17)
                        Next
                    End If
                    If MapE(x, y) = True Then
                        For tmp0 = 1 To 20 Step 1
                            canvas.DrawString("→", theexitfont, Brushes.Black, xish + 18, yish + 8)
                        Next
                    End If
                    If MapW(x, y) = True Then
                        For tmp0 = 1 To 20 Step 1
                            canvas.DrawString("←", theexitfont, Brushes.Black, xish, yish + 8)
                        Next
                    End If
                Next
            Next
        Else
            For x = 0 To 14
                For y = 0 To 14
                    xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                    yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                    xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                    If MapN(x, y) = True Then
                        For tmp0 = 1 To 20 Step 1
                            canvas.DrawString("↑", theexitfont, Brushes.White, xish + 13, yish - 1)
                        Next
                    End If
                    If MapS(x, y) = True Then
                        For tmp0 = 1 To 20 Step 1
                            canvas.DrawString("↓", theexitfont, Brushes.White, xish + 13, yish + 17)
                        Next
                    End If
                    If MapE(x, y) = True Then
                        For tmp0 = 1 To 20 Step 1
                            canvas.DrawString("→", theexitfont, Brushes.White, xish + 18, yish + 8)
                        Next
                    End If
                    If MapW(x, y) = True Then
                        For tmp0 = 1 To 20 Step 1
                            canvas.DrawString("←", theexitfont, Brushes.White, xish, yish + 8)
                        Next
                    End If
                Next
            Next
        End If
        repaint()
    End Sub
    Private Sub lockdescription(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
        If CheckBox5.Checked = False Then
            CurSectorDescription.Enabled = True
        Else
            CurSectorDescription.Enabled = False
        End If
    End Sub
    Private Sub lockmapname(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox6.CheckedChanged
        If CheckBox6.Checked = True Then
            CurMap.Enabled = False
        Else
            CurMap.Enabled = True
        End If
    End Sub
    Private Sub BeginEditor(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        DefaultTool.Checked = True
        Dim SectorNumber As Integer = 0
        Dim tmp0 As Single
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        Dim theexitfont As New Font("Arial", 6)
        Button4.Enabled = False
        Button5.Enabled = True
        GroupBox1.Enabled = True
        GroupBox2.Enabled = False
        CheckBox2.Enabled = True
        CheckBox1.Enabled = True
        LockSectorCreation.Enabled = False
        LockSectorDeletion.Enabled = False
        LockSectorLinking.Enabled = False
        SectorExitArrows.Enabled = False
        CheckBox5.Enabled = False
        CheckBox6.Enabled = False
        LockSectorLinking.Checked = True
        LockSectorCreation.Checked = True
        LockSectorDeletion.Checked = True
        For y = 0 To 14 Step 1
            For x = 0 To 14 Step 1
                If Map(x, y) <> 0 Then
                    MapNumber(x, y) = SectorNumber + 1
                    SectorNumber += 1
                    xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                    yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                    xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                    canvas.DrawString(LTrim(Str(SectorNumber)), theexitfont, Brushes.White, xish + 1, yish + 22)
                Else
                    MapNumber(x, y) = 0
                End If
            Next
        Next
        repaint()
    End Sub
    Private Sub ChangeGenerationView(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        DefaultTool.Checked = True
        Dim SectorNumber As Integer = 0
        Dim tmp0 As Single
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        Dim theexitfont As New Font("Arial", 7)
        Button4.Enabled = True
        Button5.Enabled = False
        GroupBox1.Enabled = False
        GroupBox2.Enabled = True
        CheckBox2.Enabled = False
        CheckBox1.Enabled = False
        LockSectorCreation.Enabled = True
        LockSectorDeletion.Enabled = True
        LockSectorLinking.Enabled = True
        SectorExitArrows.Enabled = True
        CheckBox5.Enabled = True
        CheckBox6.Enabled = True
        LockSectorLinking.Checked = False
        LockSectorCreation.Checked = False
        LockSectorDeletion.Checked = False
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Map(x, y) <> 0 Then
                    MapNumber(x, y) = SectorNumber + 1
                    SectorNumber += 1
                    xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                    yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                    xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                    For tmp0 = 0 To 20
                        canvas.DrawString("██", theexitfont, Brushes.Black, xish, yish + 20)
                    Next
                Else
                    MapNumber(x, y) = 0
                End If
            Next
        Next
        repaint()
    End Sub
    Private Sub ToggleNumbers(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        Dim SectorNumber As Integer = 0
        Dim tmp0 As Single
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        Dim theexitfont As New Font("Arial", 6)
        If CheckBox2.Checked = False Then
            For x = 0 To 14 Step 1
                For y = 0 To 14 Step 1
                    If Map(x, y) <> 0 Then
                        MapNumber(x, y) = SectorNumber + 1
                        SectorNumber += 1
                        xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                        yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                        xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                        yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                        For tmp0 = 0 To 20
                            canvas.DrawString("██", theexitfont, Brushes.Black, xish + 1, yish + 20)
                        Next
                    Else
                        MapNumber(x, y) = 0
                    End If
                Next
            Next
        Else
            For x = 0 To 14 Step 1
                For y = 0 To 14 Step 1
                    If Map(x, y) <> 0 Then
                        MapNumber(x, y) = SectorNumber + 1
                        SectorNumber += 1
                        xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                        yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                        xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                        yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                        canvas.DrawString(LTrim(Str(SectorNumber)), theexitfont, Brushes.White, xish + 1, yish + 22)
                    Else
                        MapNumber(x, y) = 0
                    End If
                Next
            Next
        End If
        repaint()
    End Sub
    Private Sub AccessibleChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.Checked = True Then
            MapAcessible(CurX, CurY) = 1
        Else
            MapAcessible(CurX, CurY) = 0
        End If
    End Sub
    Private Sub ChangeEnvironment(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurMapENVIRON.SelectedIndexChanged
        If PreventRedraw = False Then
            Dim tmp0 As Single
            Dim xish As Integer 'makes the code smaller, easier to read
            Dim yish As Integer 'also makes it smaller
            Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
            Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
            Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
            Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
            Dim theexitfont As New Font("Arial", 8)
            If Map(CurX, CurY) <> 0 And MapEnvironmentSet(CurX, CurY) = False Then
                MapEnvironment(CurX, CurY) = Val(Mid(CurMapENVIRON.Text, 1, 2))
                MapEnvironmentSet(CurX, CurY) = True
                xish = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10
                yish = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10
                xishPLUS = Val(TheRoomWidth) * CurX + Val(ColumnsSpace) * CurX + 10 + Val(TheRoomWidth)
                yishPLUS = Val(TheRoomHeight) * CurY + Val(RowSpace) * CurY + 10 + Val(TheRoomHeight)
                For tmp0 = 0 To 15
                    canvas.DrawString("x", theexitfont, Brushes.LightBlue, xish + 21, yish + 19)
                Next
            Else
                MapEnvironment(CurX, CurY) = Val(Mid(CurMapENVIRON.Text, 1, 2))
            End If
            CheckBox3.Select()
            For x = 0 To Val(Columns) - 1 Step 1
                For y = 0 To Val(Rows) - 1 Step 1
                    xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                    yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                    xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                    Dim ColorString As String = Replace(SetEnvironmentColor(x, y, MapEnvironment(x, y)), "0x", "#")
                    Dim CustomPen As New Pen(ColorTranslator.FromHtml(ColorString))
                    If Map(x, y) = 0 Then
                        canvas.DrawLine(Pens.DarkSlateGray, xish, yish, xishPLUS, yish)
                        canvas.DrawLine(Pens.Black, xishPLUS, yish, xishPLUS, yishPLUS)
                        canvas.DrawLine(Pens.Black, xishPLUS, yishPLUS, xish, yishPLUS)
                        canvas.DrawLine(Pens.DarkSlateGray, xish, yishPLUS, xish, yish)
                    Else
                        canvas.DrawLine(CustomPen, xish, yish, xishPLUS, yish)
                        canvas.DrawLine(CustomPen, xishPLUS, yish, xishPLUS, yishPLUS)
                        canvas.DrawLine(CustomPen, xishPLUS, yishPLUS, xish, yishPLUS)
                        canvas.DrawLine(CustomPen, xish, yishPLUS, xish, yish)
                    End If
                Next
            Next
            repaint()
        Else
            PreventRedraw = False
        End If
    End Sub
    Private Sub AddProp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddProp.Click
        MapEditorAddProp.ShowDialog()
    End Sub
    Private Sub RemoveProp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveProp.Click
        Dim comp As Boolean
        Dim tmp0 As Integer
        Dim tmp1 As Integer
        Dim tmp2 As Integer
        Dim tmpa As String = PropList.SelectedItem
        Dim tmpb As String = ""
        Dim tmpc As String = MapProps(CurX, CurY)
        For tmp0 = 1 To Len(tmpa) Step 1
            If Mid(tmpa, tmp0, 3) = "is " Then
                tmpb = Mid(tmpa, 1, tmp0 - 2)
                Exit For
            End If
        Next
        For tmp0 = 1 To Len(tmpc) + 1 Step 1
            If Mid(tmpc, tmp0, 1) = "," Then
                tmp1 += 1
                If tmp1 < PropList.SelectedIndex + 1 Then tmpb = LTrim(Str(tmp0))
                If tmp1 = PropList.SelectedIndex + 1 Then
                    If tmp1 = 1 Then
                        For tmp2 = tmp0 To Len(tmpc) Step 1
                            If Mid(tmpc, tmp2, 1) = "," Then
                                MapProps(CurX, CurY) = Mid(tmpc, tmp2 + 1, Len(tmpc))
                                comp = True
                                Exit For
                            End If
                        Next
                    Else
                        For tmp2 = tmp0 To Len(tmpc) Step 1
                            If Mid(tmpc, tmp2, 1) = "," Then
                                MapProps(CurX, CurY) = Mid(tmpc, 1, Val(tmpb)) + Mid(tmpc, tmp2 + 1, Len(tmpc))
                                comp = True
                                Exit For
                            End If
                        Next
                    End If
                    Exit For
                End If
            End If
        Next
        If PropList.Items.Count = PropList.SelectedIndex + 1 And comp = False Then
            For tmp0 = Len(tmpc) To 1 Step -1
                If Mid(tmpc, tmp0, 1) = "," Then
                    MapProps(CurX, CurY) = Mid(tmpc, 1, tmp0 - 1)
                    comp = True
                    Exit For
                End If
            Next
        End If
        If PropList.Items.Count = 1 And comp = False Then
            MapProps(CurX, CurY) = ""
            comp = True
        End If
        PropList.Items.RemoveAt(PropList.SelectedIndex)
    End Sub
    Private Sub AddMobile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddMobile.Click
        MapEditorAddMobile.ShowDialog()
    End Sub
    Private Sub RemoveMobile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveMobile.Click
        Dim comp As Boolean = False
        Dim tmp0 As Integer
        Dim tmp1 As Integer
        Dim tmp2 As Integer
        Dim tmpa As String = Mobilelist.SelectedItem
        Dim tmpb As String = ""
        Dim tmpc As String = MapMobiles(CurX, CurY)
        For tmp0 = 1 To Len(tmpa) Step 1
            If Mid(tmpa, tmp0, 3) = "is " Then
                tmpb = Mid(tmpa, 1, tmp0 - 2)
                Exit For
            End If
        Next
        For tmp0 = 1 To Len(tmpc) + 1 Step 1
            If Mid(tmpc, tmp0, 1) = "," Then
                tmp1 += 1
                If tmp1 < Mobilelist.SelectedIndex + 1 Then tmpb = LTrim(Str(tmp0))
                If tmp1 = Mobilelist.SelectedIndex + 1 Then
                    If tmp1 = 1 Then
                        For tmp2 = tmp0 To Len(tmpc) Step 1
                            If Mid(tmpc, tmp2, 1) = "," Then
                                MapMobiles(CurX, CurY) = Mid(tmpc, tmp2 + 1, Len(tmpc))
                                comp = True
                                Exit For
                            End If
                        Next
                    Else
                        For tmp2 = tmp0 To Len(tmpc) Step 1
                            If Mid(tmpc, tmp2, 1) = "," Then
                                MapMobiles(CurX, CurY) = Mid(tmpc, 1, Val(tmpb)) + Mid(tmpc, tmp2 + 1, Len(tmpc))
                                comp = True
                                Exit For
                            End If
                        Next
                    End If
                    Exit For
                End If
            End If
        Next
        If Mobilelist.Items.Count = Mobilelist.SelectedIndex + 1 And comp = False Then
            For tmp0 = Len(tmpc) To 1 Step -1
                If Mid(tmpc, tmp0, 1) = "," Then
                    MapMobiles(CurX, CurY) = Mid(tmpc, 1, tmp0 - 1)
                    Exit For
                End If
            Next
        End If
        If Mobilelist.Items.Count = 1 And comp = False Then
            MapMobiles(CurX, CurY) = ""
        End If
        Mobilelist.Items.RemoveAt(Mobilelist.SelectedIndex)
    End Sub
    Private Sub OverwriteMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OverwriteMap.Click
        If ConfirmIt.Checked = False Then
            If MessageBox.Show("Are you sure you want to overwrite the map with the current one open? This compile all information and save it to disk, all past information will no longer be obtainable as it will be overwritten.", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.OK Then
                SaveTheMap(False)
                TabControl1.SelectedTab = TabControl1.TabPages.Item(3)
            End If
        Else
            SaveTheMap(False)
            TabControl1.SelectedTab = TabControl1.TabPages.Item(3)
        End If
    End Sub
    Private Sub CompileMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompileMap.Click
        If ConfirmIt.Checked = False Then
            If MessageBox.Show("Are you sure you want to save and create this new map? This compile all information and save it to disk.", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.OK Then
                SaveTheMap(True)
                TabControl1.SelectedTab = TabControl1.TabPages.Item(3)
            End If
        Else
            SaveTheMap(True)
            TabControl1.SelectedTab = TabControl1.TabPages.Item(3)
        End If
    End Sub
    Private Sub RebukeCarriage(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles CurSectorDescription.KeyPress
        Dim keyascii As Integer = AscW(e.KeyChar)
        Dim isnumber As Boolean = Char.IsNumber(e.KeyChar)
        Dim isletter As Boolean = Char.IsLetter(e.KeyChar)
        If keyascii = 13 Then
            e.Handled = True
        End If
    End Sub
#Region "Loading AtlasNodes"
    'The following subfunction curses through AtlasNodes and pulls the worlds available within.
    'most naturally at this point it will only be Urd. At some point in the future, there may be
    'a test world
    Sub LoadWorld()
        'clear the current world list
        CurWorld.Items.Clear()
        'declare xml - Xpath dimensions
        Dim m_xmld As New XPath.XPathDocument(Debugger.DirAtlasNodes)
        Dim m_nav As XPath.XPathNavigator = m_xmld.CreateNavigator
        Dim m_nodit As XPath.XPathNodeIterator = m_nav.Select("/world")
        Try
            While m_nodit.MoveNext()
                CurWorld.Items.Add(m_nodit.Current.GetAttribute("name", ""))
            End While
            CurWorld.SelectedIndex = 0
            LoadContinent(0, EventArgs.Empty)
        Catch errorVariable As Exception
            SND("/RERROR: " + errorVariable.ToString())
        End Try
    End Sub
    'The following subfunction curses through AtlasNodes and pulls te continents available within.
    'At this point there is only Sedia, but at some point in the future, there may be an expansion
    'that may cause another continent or more to be available.
    Sub LoadContinent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurWorld.SelectedIndexChanged
        'clear the current world list
        CurContinent.Items.Clear()
        'declare xml - Xpath dimensions
        Dim m_xmld As New XPath.XPathDocument(Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", "AtlasNodes.xml"))
        Dim m_nav As XPath.XPathNavigator = m_xmld.CreateNavigator
        Dim m_nodit As XPath.XPathNodeIterator = m_nav.Select("/world[@name='" + CurWorld.Text + "']/continent")
        Try
            While m_nodit.MoveNext()
                CurContinent.Items.Add(m_nodit.Current.GetAttribute("name", ""))
            End While
            CurContinent.SelectedIndex = 0
            Loadprovince(0, EventArgs.Empty)
        Catch errorVariable As Exception
            SND("/RERROR: " + errorVariable.ToString())
        End Try
    End Sub
    'The following subfunction curses through AtlasNodes and pulls the Provinces. 
    'Like World and Continent, provinces are all now set in stone.
    Sub Loadprovince(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurContinent.SelectedIndexChanged
        'clear the current world list
        CurProvince.Items.Clear()
        'declare xml - Xpath dimensions
        Dim m_xmld As New XPath.XPathDocument(Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", "AtlasNodes.xml"))
        Dim m_nav As XPath.XPathNavigator = m_xmld.CreateNavigator
        Dim m_nodit As XPath.XPathNodeIterator = m_nav.Select("/world[@name='" + CurWorld.Text + "']/continent[@name='" + CurContinent.Text + "']/province")
        Try
            While m_nodit.MoveNext()
                CurProvince.Items.Add(m_nodit.Current.GetAttribute("name", ""))
            End While
            CurProvince.SelectedIndex = 0
            Loadarea(0, EventArgs.Empty)
        Catch errorVariable As Exception
            SND("/RERROR: " + errorVariable.ToString())
        End Try
    End Sub
    'The following subfunction curses through AtlasNodes and pulls the Areas.
    'The areas are all set in stone and contain other important information such as level requirement etc
    'that should be utilized within Clay to ensure that the builder is creating maps that fit the areas
    'requirements.
    Sub Loadarea(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurProvince.SelectedIndexChanged
        'clear the current world list
        CurArea.Items.Clear()
        'declare xml - Xpath dimensions
        Dim m_xmld As New XPath.XPathDocument(Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", "AtlasNodes.xml"))
        Dim m_nav As XPath.XPathNavigator = m_xmld.CreateNavigator
        Dim m_nodit As XPath.XPathNodeIterator = m_nav.Select("/world[@name='" + CurWorld.Text + "']/continent[@name='" + CurContinent.Text + "']/province[@name='" + CurProvince.Text + "']/area")
        Try
            While m_nodit.MoveNext()
                CurArea.Items.Add(m_nodit.Current.GetAttribute("name", ""))
            End While
            CurArea.SelectedIndex = 0
            LoadMaps(0, EventArgs.Empty)
        Catch errorVariable As Exception
            SND("/RERROR: " + errorVariable.ToString())
        End Try
    End Sub
    'The following subfunction curses through AtlasNodes and pulls the maps.
    'The only maps pulled are those from the selected area. This is just the maplist
    'once the map is selected it can be loaded by clicking on it in the combobox
    Sub LoadMaps(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurArea.SelectedIndexChanged
        'clear the current map list
        CurLoadMaps.Items.Clear()
        'declare xml - Xpath dimensions
        Dim m_xmld As New XPath.XPathDocument(Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", "AtlasNodes.xml"))
        Dim m_nav As XPath.XPathNavigator = m_xmld.CreateNavigator
        Dim m_nodit As XPath.XPathNodeIterator = m_nav.Select("/world[@name='" + CurWorld.Text + "']/continent[@name='" + CurContinent.Text + "']/province[@name='" + CurProvince.Text + "']/area[@name='" + CurArea.Text + "']")
        'Now that the area is loaded, update the required level of area, the sentient races,
        'the default environment, and other important information for the area that all maps
        'within it should follow
        WorldInfo.Text = CurWorld.Text
        ContinentInfo.Text = CurContinent.Text
        ProvinceInfo.Text = CurProvince.Text
        m_nodit.MoveNext() 'required to read the current node, pushes node into reader
        AreaInfo.Text = CurArea.Text
        LevelRangeInfo.Text = m_nodit.Current.GetAttribute("minimumlevel", "") + "-" + m_nodit.Current.GetAttribute("maximumlevel", "")
        DefaultEnvironmentInfo.Text = m_nodit.Current.GetAttribute("environment", "")
        SentientRacesInfo.Text = m_nodit.Current.GetAttribute("sentientraces", "")
        'RequiredLevelInfo.Text=
        'Now that the status bar information has been completed, continue by loading the maps for the selected area
        m_nodit = m_nav.Select("/world[@name='" + CurWorld.Text + "']/continent[@name='" + CurContinent.Text + "']/province[@name='" + CurProvince.Text + "']/area[@name='" + CurArea.Text + "']/map")
        Try
            While m_nodit.MoveNext()
                CurLoadMaps.Items.Add(m_nodit.Current.GetAttribute("name", ""))
            End While
        Catch errorVariable As Exception
            SND("/RERROR: " + errorVariable.ToString())
        End Try
    End Sub
    'The following subfunction is utilized after the user clicks on the map, and attempts to decipher
    Private Sub LoadTheMap(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurLoadMaps.SelectedIndexChanged
        Dim LoadMap As Boolean = False
        If ConfirmIt.Checked = True Then 'this is to ensure that the suppress dialogue option has been used, if it has, then it's not necessary
            If MessageBox.Show("Loading a new map will discard all changes if you haven't saved the map you're currently working on. Are you sure you want to load a new map?", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.OK Then
                LoadMap = True
                DescriptorToggle.Checked = False
                DescriptorToggle.Enabled = True
            End If
        Else
            LoadMap = True
            DescriptorToggle.Checked = False
            DescriptorToggle.Enabled = True
        End If
        If LoadMap = True Then 'loadmap
            'clear map first
            ClearMap(0, EventArgs.Empty)
            'declare xml - Xpath dimensions
            'Note that the XPATH cannot have spaces, so we remove them with replace
            Dim m_xmld As New XPath.XPathDocument(Replace(Debugger.DirAtlasNodes, "AtlasNodes.xml", Replace(CurContinent.Text + "/" + CurProvince.Text + "/" + CurArea.Text + "/" + CurLoadMaps.Text + ".xml", " ", "")))
            Dim m_nav As XPath.XPathNavigator = m_xmld.CreateNavigator
            Dim m_nodit As XPath.XPathNodeIterator = m_nav.Select("/map")
            m_nodit.MoveNext() 'initiates the nodes
            'Set the maps name
            CurMap.Text = m_nodit.Current.GetAttribute("name", "")
            'Set the maps creator name
            MapCreator.Text = m_nodit.Current.GetAttribute("creator", "")
            'Set the maps description
            m_nodit.Current.MoveToChild("description", "")
            Notes.Text = m_nodit.Current.Value
            'Curse through and set the environments
            m_nodit.Current.MoveToParent()
            m_nodit.Current.MoveToChild("environmentmap", "")
            Dim CurserPosition, CurrentCurse As Short
            Dim X, Y As Short, CurString As String
            'Let's go ahead and save the vnum locations when we curse through this time so we know where to save them when we curse through
            'the actual rooms next
            Dim VNUMlocationX(255), VNUMlocationY(255), TotalVNUMs As Byte 'won't hit 255 in a 15x15 square
            For CurserPosition = 1 To Len(m_nodit.Current.Value) Step 1
                If Mid(m_nodit.Current.Value, CurserPosition, 1) = "," Then
                    CurrentCurse += 1
                    If CurrentCurse Mod 2 = 1 Then 'if it's an odd number then it's an environment position
                        Y = Math.Ceiling(CurrentCurse / 30) - 1
                        X = Math.Ceiling((CurrentCurse - 30 * Y) / 2) - 1
                        CurString = Mid(m_nodit.Current.Value, CurserPosition + 1, 3)
                        If Val(CurString) < 100 Then
                            Map(X, Y) = 1
                            'increase the total of rooms available
                            TotalVNUMs += 1
                            'save the location of the current vnum for room access later
                            VNUMlocationX(TotalVNUMs) = X : VNUMlocationY(TotalVNUMs) = Y
                            MapEnvironment(X, Y) = CurString
                        Else
                            Map(X, Y) = 0
                            MapEnvironment(X, Y) = 0
                        End If
                    End If
                End If
            Next
            'Curse through and set the linkage
            m_nodit.Current.MoveToParent()
            m_nodit.Current.MoveToChild("exitmap", "")
            'clear curser tha twas declared for environments, and reuse it
            CurserPosition = 0 : CurrentCurse = 0
            'declare the dimension for drawing arrows
            Dim xish, yish As Integer 'makes the code smaller, easier to read
            Dim xishPLUS, yishPLUS As Integer
            Dim TheRoomWidth As Integer = 32, TheRoomHeight As Integer = 32
            Dim RowSpace As Integer = 5, ColumnsSpace As Integer = 5
            'temporary byte used for drawing
            Dim TMP0 As Byte
            'the font must stay the same, it fits just perfect
            Dim theexitfont As New Font("Arial", 8)
            'now lets curse
            For CurserPosition = 1 To Len(m_nodit.Current.Value) Step 1
                If Mid(m_nodit.Current.Value, CurserPosition, 1) = "," Then
                    CurrentCurse += 1
                    Y = Math.Ceiling(CurrentCurse / 15) - 1
                    X = Math.Ceiling(CurrentCurse - 15 * Y) - 1
                    CurString = Mid(m_nodit.Current.Value, CurserPosition - 6, 6)
                    'now prepare to draw the connection if it was found
                    xish = TheRoomWidth * X + ColumnsSpace * X + 10
                    yish = TheRoomHeight * Y + RowSpace * Y + 10
                    If InStr(CurString, "N") Then
                        MapN(X, Y) = True
                        For TMP0 = 1 To 20 Step 1 : canvas.DrawString("↑", theexitfont, Brushes.White, xish + 13, yish - 1) : Next
                    End If
                    If InStr(CurString, "S") Then
                        MapS(X, Y) = True
                        For TMP0 = 1 To 20 Step 1 : canvas.DrawString("↓", theexitfont, Brushes.White, xish + 13, yish + 17) : Next
                    End If
                    If InStr(CurString, "E") Then
                        MapE(X, Y) = True
                        For TMP0 = 1 To 20 Step 1 : canvas.DrawString("→", theexitfont, Brushes.White, xish + 18, yish + 8) : Next
                    End If
                    If InStr(CurString, "W") Then
                        MapW(X, Y) = True
                        For TMP0 = 1 To 20 Step 1 : canvas.DrawString("←", theexitfont, Brushes.White, xish, yish + 8) : Next
                    End If
                    If InStr(CurString, "U") Then MapU(X, Y) = True
                    If InStr(CurString, "D") Then MapD(X, Y) = True
                End If
            Next
            m_nodit = m_nav.Select("/map/sectorlist/sector")
            While m_nodit.MoveNext()
                X = VNUMlocationX(m_nodit.Current.GetAttribute("number", ""))
                Y = VNUMlocationY(m_nodit.Current.GetAttribute("number", ""))
                MapSafe(X, Y) = Replace(Replace(m_nodit.Current.GetAttribute("saferoom", ""), "False", "0"), "True", "1")
                MapAcessible(X, Y) = Replace(Replace(m_nodit.Current.GetAttribute("accessible", ""), "False", "0"), "True", "1")
                m_nodit.Current.MoveToChild("exits", "")
                MapNorth(X, Y) = m_nodit.Current.GetAttribute("north", "")
                MapSouth(X, Y) = m_nodit.Current.GetAttribute("south", "")
                MapEast(X, Y) = m_nodit.Current.GetAttribute("east", "")
                MapWest(X, Y) = m_nodit.Current.GetAttribute("west", "")
                MapUp(X, Y) = m_nodit.Current.GetAttribute("up", "")
                MapDown(X, Y) = m_nodit.Current.GetAttribute("down", "")
                If InStr(MapUp(X, Y), "[") Or InStr(MapDown(X, Y), "[") Then
                    Dim ThePen As New Pen(Color.LightGray, 1)
                    ThePen.DashStyle = Drawing2D.DashStyle.Dot
                    xish = Val(TheRoomWidth) * X + Val(ColumnsSpace) * X + 10
                    yish = Val(TheRoomHeight) * Y + Val(RowSpace) * Y + 10
                    xishPLUS = Val(TheRoomWidth) * X + Val(ColumnsSpace) * X + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * Y + Val(RowSpace) * Y + 10 + Val(TheRoomHeight)
                    canvas.DrawLine(ThePen, xish - 2, yish - 2, xishPLUS + 2, yish - 2)
                    canvas.DrawLine(ThePen, xishPLUS + 2, yish - 2, xishPLUS + 2, yishPLUS + 2)
                    canvas.DrawLine(ThePen, xishPLUS + 2, yishPLUS + 2, xish - 2, yishPLUS + 2)
                    canvas.DrawLine(ThePen, xish - 2, yishPLUS + 2, xish - 2, yish - 2)
                End If
                m_nodit.Current.MoveToParent()
                m_nodit.Current.MoveToChild("title", "")
                MapDesc(X, Y) = m_nodit.Current.Value
                m_nodit.Current.MoveToParent()
                m_nodit.Current.MoveToChild("description", "")
                MapDescription(X, Y) = m_nodit.Current.Value
                m_nodit.Current.MoveToParent()
                m_nodit.Current.MoveToChild("characters", "")
                MapMobiles(X, Y) = m_nodit.Current.Value
                m_nodit.Current.MoveToParent()
                m_nodit.Current.MoveToChild("props", "")
                MapProps(X, Y) = m_nodit.Current.Value
                'the following is only available on live servers
                'm_nodit.Current.MoveToParent()
                'm_nodit.Current.MoveToChild("droppeditems", "")
                'MapDroppedItems(X, Y) = m_nodit.Current.Value
            End While
            ChangeEnvironment(0, EventArgs.Empty)
            BeginEditor(0, EventArgs.Empty)
            repaint()
        End If
    End Sub
#End Region
#Region "Tools"
    Private Sub ChangeToDefault(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DefaultTool.CheckedChanged
        If DefaultTool.Checked = True Then
            SectorExitArrows.Checked = True
            LockSectorCreation.Checked = False
            LockSectorDeletion.Checked = False
            LockSectorLinking.Checked = False
            CheckBox5.Checked = False
            CheckBox6.Checked = False
        End If
    End Sub
    Private Sub CreateAndDeleteOnly(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateAndDeleteTool.CheckedChanged
        If CreateAndDeleteTool.Checked = True Then
            SectorExitArrows.Checked = True
            LockSectorCreation.Checked = False
            LockSectorDeletion.Checked = False
            LockSectorLinking.Checked = True
            CheckBox5.Checked = False
            CheckBox6.Checked = False
        End If
    End Sub
    Private Sub LinkingSectorsOnly(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkingOnly.CheckedChanged
        If LinkingOnly.Checked = True Then
            SectorExitArrows.Checked = True
            LockSectorCreation.Checked = True
            LockSectorDeletion.Checked = True
            LockSectorLinking.Checked = False
            CheckBox5.Checked = False
            CheckBox6.Checked = False
        End If
    End Sub
#End Region
#Region "Set and Clear Buttons"
    'Clear all links
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                MapN(x, y) = False
                MapNorth(x, y) = "0"
                MapS(x, y) = False
                MapSouth(x, y) = "0"
                MapE(x, y) = False
                MapEast(x, y) = "0"
                MapW(x, y) = False
                MapWest(x, y) = "0"
                MapU(x, y) = False
                MapUp(x, y) = "0"
                MapD(x, y) = False
                MapDown(x, y) = "0"
            Next
        Next
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim changed As Boolean = False, finishedit As Boolean = False
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim skip As Boolean = False
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        For x = 0 To Val(Columns) - 1 Step 1
            For y = 0 To Val(Rows) - 1 Step 1
                xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                Dim ColorString As String = Replace(SetEnvironmentColor(x, y, MapEnvironment(x, y)), "0x", "#")
                Dim CustomPen As New Pen(ColorTranslator.FromHtml(ColorString))
                If Map(x, y) = 2 Then
                    canvas.DrawLine(Pens.DarkSlateGray, xish, yish, xishPLUS, yish)
                    canvas.DrawLine(Pens.Black, xishPLUS, yish, xishPLUS, yishPLUS)
                    canvas.DrawLine(Pens.Black, xishPLUS, yishPLUS, xish, yishPLUS)
                    canvas.DrawLine(Pens.DarkSlateGray, xish, yishPLUS, xish, yish)
                Else
                    canvas.DrawLine(CustomPen, xish, yish, xishPLUS, yish)
                    canvas.DrawLine(CustomPen, xishPLUS, yish, xishPLUS, yishPLUS)
                    canvas.DrawLine(CustomPen, xishPLUS, yishPLUS, xish, yishPLUS)
                    canvas.DrawLine(CustomPen, xish, yishPLUS, xish, yish)
                End If
            Next
        Next
        Dim theexitfont As New Font("Arial", 8)
        Dim theothefont As New Font("Arial", 4)
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    If Map(x, y) <> 0 Then
                        xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                        yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                        xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                        yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                        Dim tmp0 As Short = 0
                        MapAcessible(x, y) = True
                        If MapN(x, y) = True Then
                            For tmp0 = 0 To 20 Step 1
                                canvas.DrawString("↑", theexitfont, Brushes.White, xish + 13, yish - 1)
                            Next
                        Else
                            For tmp0 = 0 To 20 Step 1
                                canvas.DrawString("↑", theexitfont, Brushes.Black, xish + 13, yish - 1)
                            Next
                        End If
                        If MapS(x, y) = True Then
                            For tmp0 = 0 To 20 Step 1
                                canvas.DrawString("↓", theexitfont, Brushes.White, xish + 13, yish + 17)
                            Next
                        Else
                            For tmp0 = 0 To 20 Step 1
                                canvas.DrawString("↓", theexitfont, Brushes.Black, xish + 13, yish + 17)
                            Next
                        End If
                        If MapE(x, y) = True Then
                            For tmp0 = 0 To 20 Step 1
                                canvas.DrawString("→", theexitfont, Brushes.White, xish + 18, yish + 8)
                            Next
                        Else
                            For tmp0 = 0 To 20 Step 1
                                canvas.DrawString("→", theexitfont, Brushes.Black, xish + 18, yish + 8)
                            Next
                        End If
                        If MapW(x, y) = True Then
                            For tmp0 = 0 To 20 Step 1
                                canvas.DrawString("←", theexitfont, Brushes.White, xish, yish + 8)
                            Next
                        Else
                            For tmp0 = 0 To 20 Step 1
                                canvas.DrawString("←", theexitfont, Brushes.Black, xish, yish + 8)
                            Next
                        End If
                        If MapU(x, y) = False And MapD(x, y) = False Then
                            Dim ThePen As New Pen(Color.Black, 1)
                            ThePen.DashStyle = Drawing2D.DashStyle.Dot
                            xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                            yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                            xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                            yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                            For tmp0 = 0 To 5 Step 1
                                canvas.DrawLine(ThePen, xish - 2, yish - 2, xishPLUS + 2, yish - 2)
                                canvas.DrawLine(ThePen, xishPLUS + 2, yish - 2, xishPLUS + 2, yishPLUS + 2)
                                canvas.DrawLine(ThePen, xishPLUS + 2, yishPLUS + 2, xish - 2, yishPLUS + 2)
                                canvas.DrawLine(ThePen, xish - 2, yishPLUS + 2, xish - 2, yish - 2)
                            Next
                        End If
                    End If
                End If
            Next
        Next
        repaint()
    End Sub
    Private Sub ClearAllDescriptions(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    MapDescription(x, y) = "You are here."
                End If
            Next
        Next
    End Sub
    Private Sub ClearAllSectorNames(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    MapDesc(x, y) = "Sector Name Goes Here"
                End If
            Next
        Next
    End Sub
    Private Sub PainEnvironment(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        Dim xish As Integer 'makes the code smaller, easier to read
        Dim yish As Integer 'also makes it smaller
        Dim changed As Boolean = False, finishedit As Boolean = False
        Dim Columns As Integer = 15, Rows As Integer = 15, TheRoomWidth As Integer = 32
        Dim TheRoomHeight As Integer = 32, RowSpace As Integer = 5, ColumnsSpace As Integer = 5
        Dim skip As Boolean = False
        Dim xishPLUS As Integer = Val(Columns) * Val(TheRoomWidth) + Val(Columns) * Val(RowSpace)
        Dim yishPLUS As Integer = Val(Rows) * Val(TheRoomHeight) + Val(Rows) * Val(ColumnsSpace)
        For x = 0 To Val(Columns) - 1 Step 1
            For y = 0 To Val(Rows) - 1 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    MapEnvironment(x, y) = MapEnvironment(CurX, CurY)
                    xish = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10
                    yish = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10
                    xishPLUS = Val(TheRoomWidth) * x + Val(ColumnsSpace) * x + 10 + Val(TheRoomWidth)
                    yishPLUS = Val(TheRoomHeight) * y + Val(RowSpace) * y + 10 + Val(TheRoomHeight)
                    Dim ColorString As String = Replace(SetEnvironmentColor(x, y, MapEnvironment(x, y)), "0x", "#")
                    Dim CustomPen As New Pen(ColorTranslator.FromHtml(ColorString))
                    If Map(x, y) = 0 Then
                        canvas.DrawLine(Pens.DarkSlateGray, xish, yish, xishPLUS, yish)
                        canvas.DrawLine(Pens.Black, xishPLUS, yish, xishPLUS, yishPLUS)
                        canvas.DrawLine(Pens.Black, xishPLUS, yishPLUS, xish, yishPLUS)
                        canvas.DrawLine(Pens.DarkSlateGray, xish, yishPLUS, xish, yish)
                    Else
                        canvas.DrawLine(CustomPen, xish, yish, xishPLUS, yish)
                        canvas.DrawLine(CustomPen, xishPLUS, yish, xishPLUS, yishPLUS)
                        canvas.DrawLine(CustomPen, xishPLUS, yishPLUS, xish, yishPLUS)
                        canvas.DrawLine(CustomPen, xish, yishPLUS, xish, yish)
                    End If
                End If
            Next
        Next
        repaint()
    End Sub
    Private Sub ClearAllProps(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    If Map(x, y) <> 0 Then
                        MapProps(x, y) = ""
                    End If
                End If
            Next
        Next
    End Sub
    Private Sub ClearAllSectorMobiles(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    If Map(x, y) <> 0 Then
                        MapMobiles(x, y) = ""
                    End If
                End If
            Next
        Next
    End Sub
    Private Sub SafeRoomChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
        If CheckBox7.Checked = True Then
            MapSafe(CurX, CurY) = 1
        Else
            MapSafe(CurX, CurY) = 0
        End If
    End Sub
    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    If Map(x, y) <> 0 Then
                        MapAcessible(x, y) = True
                    End If
                End If
            Next
        Next
    End Sub
    Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    If Map(x, y) <> 0 Then
                        MapSafe(x, y) = True
                    End If
                End If
            Next
        Next
    End Sub
    Private Sub Button7_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    If Map(x, y) <> 0 Then
                        MapSafe(x, y) = False
                    End If
                End If
            Next
        Next
    End Sub
    Private Sub Button8_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    If Map(x, y) <> 0 Then
                        MapDescription(x, y) = MapDescription(CurX, CurY)
                    End If
                End If
            Next
        Next
    End Sub
    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        For x = 0 To 14 Step 1
            For y = 0 To 14 Step 1
                If Change_Anything.Checked = True Or Change_Inside.Checked = True And MapEnvironment(x, y) = 0 Or Change_NonInside.Checked = True And MapEnvironment(x, y) <> 0 Or Change_SameEnvironment.Checked = True And MapEnvironment(x, y) = MapEnvironment(CurX, CurY) Then
                    If Map(x, y) <> 0 Then
                        MapAcessible(x, y) = False
                    End If
                End If
            Next
        Next
    End Sub
#End Region
#Region "Help Text"
    Private Sub Sectorexitarrowshelpbar(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SectorExitArrows.MouseMove
        HelpBar.Text = "[HELP - Sector Exit Arrow]" + Chr(13) + "Shows or hides exit arrows on the sectors of the map. Exit arrows symbolize the directions in which a sector connects to another sector."
    End Sub
    Private Sub locksectordescriptionhelpbar(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CheckBox5.MouseMove
        HelpBar.Text = "[HELP - Lock Sector Description]" + Chr(13) + "Prevents or enables the ability to edit the sectors descriptions. This can help if you have a tendency to accidentally clear or edit the descriptions."
    End Sub
    Private Sub locksectorlinkinghelpdisplay(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LockSectorLinking.MouseMove
        HelpBar.Text = "[HELP - Lock Sector Linking]" + Chr(13) + "Prevents rooms from being linked to one another, creating exit points between sectors."
    End Sub
    Private Sub locksectornameshelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CheckBox6.MouseMove
        HelpBar.Text = "[HELP - Lock Sector Name]" + Chr(13) + "Prevents editing of sector names. This can help if you have a tendency to accidentally edit names, or want to ensure that you don't while making changes."
    End Sub
    Private Sub locksectorcreationhelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LockSectorCreation.MouseMove
        HelpBar.Text = "[HELP - Lock Sector Creation]" + Chr(13) + "Prevents the creation of new sectors. This can help you remain in a sector type change only mode."
    End Sub
    Private Sub locksectortypechangehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        HelpBar.Text = "[HELP - Lock Sector Type Change]" + Chr(13) + "Prevents sector types from being changed. This can help you remain in sector creation mode."
    End Sub
    Private Sub locksectordeletionhelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LockSectorDeletion.MouseMove
        HelpBar.Text = "[HELP - Lock Sector Deletion]" + Chr(13) + "Prevents sectors from being deleted."
    End Sub
    Private Sub locksectordefaulttypehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        HelpBar.Text = "[HELP - Lock Sector Default Type]" + Chr(13) + "Locks sector types into their default setting."
    End Sub
    Private Sub insidetypechangehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        HelpBar.Text = "[HELP - Type Change: Inside]" + Chr(13) + "Changes the default sector type to inside. Sector Types affect how environments affect the players. You can't be hit by rain if you're inside a building."
    End Sub
    Private Sub regulartypechangehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        HelpBar.Text = "[HELP - Type Change: Default]" + Chr(13) + "Changes the default sector type to standard / default. The standard type would be outside of buildings and within the environment, susceptible to it's affects."
    End Sub
    Private Sub undergroundtypechangehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        HelpBar.Text = "[HELP - Type Change: Underground]" + Chr(13) + "Changes the default sector type to underground. Underground affects environments and how they influence players."
    End Sub
    Private Sub linkingmodehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LinkingOnly.MouseMove
        HelpBar.Text = "[HELP - Linking Mode]" + Chr(13) + "Linking mode allows the editor to ensure that all he is allowed to do is link sectors to each other to prevent accidental changes."
    End Sub
    Private Sub changingsectortypehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        HelpBar.Text = "[HELP - Type Change Mode]" + Chr(13) + "Type change mode allows the editor to more easily change sector types without deleting or linking them on accident."
    End Sub
    Private Sub creatinganddeletingmodehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CreateAndDeleteTool.MouseMove
        HelpBar.Text = "[HELP - Creation Mode]" + Chr(13) + "Creation mode allows the editor to create or delete sectors quickly without changing types. It uses the default type."
    End Sub
    Private Sub defaultmodehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DefaultTool.MouseMove
        HelpBar.Text = "[HELP - Default Mode]" + Chr(13) + "Default mode allows the editor to have access to all editing types at the same time but can prohibit him or her to quickly make changes."
    End Sub
    Private Sub manualmodehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        HelpBar.Text = "[HELP - Manual Mode]" + Chr(13) + "Manual mode allows the editor to edit freely. Use sparingly and only when necessary."
    End Sub
    Private Sub editingviewsectornumbershelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CheckBox2.MouseMove
        HelpBar.Text = "[HELP - Sector Numbers]" + Chr(13) + "Sector numbers will show the editor the actual sector VNUM's he or she is editing. Not necessary to compile."
    End Sub
    Private Sub editingviewsectorexitarrowshelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CheckBox1.MouseMove
        HelpBar.Text = "[HELP - Sector Exit Arrow]" + Chr(13) + "Shows or hides exit arrows on the sectors of the map. Exit arrows symbolize the directions in which a sector connects to another sector."
    End Sub
    Private Sub enableeditingviewhelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button4.MouseMove
        HelpBar.Text = "[HELP - Editing View Enable]" + Chr(13) + "Enables editing view and it's options. Use when editing the individual sectors."
    End Sub
    Private Sub generationviewhelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button5.MouseMove
        HelpBar.Text = "[HELP - Generation View Enable]" + Chr(13) + "Enables generation view and it's options. Use when creating, linking, and type editing of sectors."
    End Sub
    Private Sub setallcurrentenvironmentshowhelp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button13.MouseMove
        HelpBar.Text = "[HELP - Set All Current Environment]" + Chr(13) + "Sets all active sectors to have the same environment type that the currently selected sector has."
    End Sub
    Private Sub setallsaferoomhelpedit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button6.MouseMove
        HelpBar.Text = "[HELP - Set All Safe Room]" + Chr(13) + "Sets all active sectors to be safe rooms, which increases the regeneration rates drastically. Only do this in towns."
    End Sub
    Private Sub setallnonsaferoomhelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button7.MouseMove
        HelpBar.Text = "[HELP - Set All Non-safe Room]" + Chr(13) + "Sets all active sectors to not be safe rooms, which forces them to have regular regeneration rates."
    End Sub
    Private Sub setallcurrentdescriptionhelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button8.MouseMove
        HelpBar.Text = "[HELP - Set All Current Description]" + Chr(13) + "Sets all active sectors to have the same description as the currently selected sector."
    End Sub
    Private Sub Setallaccessiblehelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button16.MouseMove
        HelpBar.Text = "[HELP - Set All Accessible]" + Chr(13) + "Sets all active sectors to be accessible."
    End Sub
    Private Sub setallnonaccessible(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button17.MouseMove
        HelpBar.Text = "[HELP - Set All Non-accessible]" + Chr(13) + "Sets all active sectors to not be accessible."
    End Sub
    Private Sub clearallsectornameshelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button12.MouseMove
        HelpBar.Text = "[HELP - Clear All Sector Names]" + Chr(13) + "Clears all active sectors name variable."
    End Sub
    Private Sub clearalldescriptionshelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button11.MouseMove
        HelpBar.Text = "[HELP - Clear All Descriptions]" + Chr(13) + "Clears all active sectors descriptions."
    End Sub
    Private Sub clearalllinksbetweencells(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseMove
        HelpBar.Text = "[HELP - Clear All Links]" + Chr(13) + "Clears all exit's between active sectors of the map."
    End Sub
    Private Sub clearallsectormobileshelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button15.MouseMove
        HelpBar.Text = "[HELP - Clear All Mobiles]" + Chr(13) + "Clears all mobiles throughout the entire map."
    End Sub
    Private Sub clearallsectorpropshelpshow(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button14.MouseMove
        HelpBar.Text = "[HELP - Clear All Props]" + Chr(13) + "Clears all props throughout the entire map."
    End Sub
    Private Sub ChangeOnlyAnythingShowHelp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Change_Anything.MouseMove
        HelpBar.Text = "[HELP - Change Anything]" + Chr(13) + "Any 'Set' or 'Clear' actions will affect all non-empty squares."
    End Sub
    Private Sub ChangeOnlyInsideShowHelp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Change_Inside.MouseMove
        HelpBar.Text = "[HELP - Change Inside Only]" + Chr(13) + "Any 'Set' or 'Clear' actions will affect only sectors that have the 'Inside' environment."
    End Sub
    Private Sub ChangeNonInsideShowHelp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Change_NonInside.MouseMove
        HelpBar.Text = "[HELP - Change Non-Inside Only]" + Chr(13) + "Any 'Set' or 'Clear' actions will affect only sectors that aren't the 'Inside' environment."
    End Sub
    Private Sub ChangeOnlySameEnvironmentShowHelp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Change_SameEnvironment.MouseMove
        HelpBar.Text = "[HELP - Change This Environment Only]" + Chr(13) + "Any 'Set' or 'Clear' actions will affect only sectors that share the same sectors environment."
    End Sub
#End Region
End Class